65 lines
1.6 KiB
Markdown
65 lines
1.6 KiB
Markdown
# Code Snippets
|
|
|
|
Backend application to store my code snippets and make them available via REST API.
|
|
|
|
[TUI CMS / MCP server companion project](https://git.travisshears.com/travisshears/snippets_cms)
|
|
|
|
This project is written in [Clojure](https://clojure.org/) and data is stored in [XTDB](https://xtdb.dev/).
|
|
|
|
## Links
|
|
|
|
- [reitit docs](https://cljdoc.org/d/metosin/reitit/0.9.1/doc/introduction)
|
|
- [basic web development clojure tutorial](https://clojure-doc.org/articles/tutorials/basic_web_development/)
|
|
- [reitit malli coercion](https://cljdoc.org/d/metosin/reitit/0.9.1/doc/coercion/malli)
|
|
- [malli docs](https://github.com/metosin/malli)
|
|
- [xtdb docs](https://docs.xtdb.com/drivers/clojure/codox/xtdb.api.html#var-execute-tx)
|
|
|
|
## Dev
|
|
|
|
### How to run dev server
|
|
|
|
Run the server
|
|
|
|
```
|
|
$ clojure -M -m snippets.main
|
|
```
|
|
|
|
Hot reload:
|
|
|
|
```shell
|
|
$ fd -e clj | entr -r clojure -M -m snippets.main
|
|
```
|
|
|
|
### Repl
|
|
|
|
Connect to the repl of running app
|
|
|
|
```shell
|
|
$ rlwrap nc localhost 5555
|
|
```
|
|
|
|
Or start up fresh repl
|
|
|
|
```
|
|
$ rlwrap clojure
|
|
; print stuff
|
|
(clojure.pprint/pprint {:name "Alice" :age 30})
|
|
; import modules
|
|
(require 'clojure.string)
|
|
(require '[clojure.string :as str])
|
|
(require 'my.namespace :reload)
|
|
; list namespace contense
|
|
(dir clojure.string)
|
|
; Switch into a namespace
|
|
(in-ns 'my.namespace)
|
|
(in-ns 'user)
|
|
```
|
|
|
|
### How to create docker image
|
|
|
|
At this point I'm using a private AWS ECR repository for the project and deploying it in my homelab.
|
|
|
|
```shell
|
|
$ export AWS_PROFILE=personal
|
|
$ docker buildx build --platform linux/amd64,linux/arm64 -t 853019563312.dkr.ecr.eu-central-1.amazonaws.com/snippets-homelabstack:latest --push .
|
|
```
|