diff --git a/Dockerfile b/Dockerfile index 322e0bd..3b4e7e3 100644 --- a/Dockerfile +++ b/Dockerfile @@ -22,8 +22,6 @@ RUN clj -P COPY build.clj config.edn ./ COPY src ./src -ENV DATOMIC_PATH=/datomic_data -ENV DATOMIC_ENV=prd # construct the application jar RUN clj -T:build uber && cp target/snippets-standalone.jar ./app.jar && rm -r target diff --git a/README.md b/README.md index 11f88ea..6a01a49 100644 --- a/README.md +++ b/README.md @@ -32,14 +32,6 @@ $ 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 diff --git a/bruno/CodeSnippets/bruno.json b/bruno/CodeSnippets/bruno.json index f6f6e53..3858af6 100644 --- a/bruno/CodeSnippets/bruno.json +++ b/bruno/CodeSnippets/bruno.json @@ -1,6 +1,6 @@ { "version": "1", - "name": "Snippets", + "name": "CodeSnippets", "type": "collection", "ignore": [ "node_modules", diff --git a/dev.sh b/dev.sh deleted file mode 100755 index 06eef21..0000000 --- a/dev.sh +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/sh - -fd -e clj | entr -r clojure -M -m snippets.main \ No newline at end of file diff --git a/src/snippets/infra/api.clj b/src/snippets/infra/api.clj index a7d31bb..1bae601 100644 --- a/src/snippets/infra/api.clj +++ b/src/snippets/infra/api.clj @@ -2,6 +2,7 @@ (:require [ring.adapter.jetty :as jetty] [clojure.pprint :as pprint] + [clojure.string :as str] [taoensso.telemere :as t] [snippets.use-cases.view] [snippets.use-cases.delete] diff --git a/src/snippets/infra/config.clj b/src/snippets/infra/config.clj index 56a9e41..c010003 100644 --- a/src/snippets/infra/config.clj +++ b/src/snippets/infra/config.clj @@ -14,7 +14,5 @@ (defn get-config [] (-> (static-config) - (assoc-in-not-nil [:datomic :storage-dir] (env :datomic-path)) - (assoc-in-not-nil [:datomic :system] (env :datomic-env)) (assoc-in-not-nil [:jetty :host] (env :host)) (assoc-in-not-nil [:jetty :port] (safe-parse-int (env :port))))) diff --git a/src/snippets/infra/db2.clj b/src/snippets/infra/db2.clj index 277961c..134f93a 100644 --- a/src/snippets/infra/db2.clj +++ b/src/snippets/infra/db2.clj @@ -3,18 +3,14 @@ [clojure.set :as set] [datomic.client.api :as d] [malli.core :as m] - [snippets.infra.config :as config] [taoensso.telemere :as t])) ;; Initialize the Datomic Local client ;; :system "dev" groups your databases in the "dev" system ;; In production, you'd set :storage-dir to a persistent path ;; TODO: add save file location for prod - -(def datomic-config (:datomic (config/get-config))) - -(def client (d/client (merge {:server-type :datomic-local - :system "dev"} datomic-config))) +(def client (d/client {:server-type :datomic-local + :system "dev"})) (def db-name "snippets") @@ -106,7 +102,7 @@ [entity] (m/validate create-schema entity)) -(defn create-snippets +(defn- put-snippets "Create new snippets in the database." [snippets] (t/log! {:level :info, :data {:slugs (map :slug snippets)}} "Saving new snippets to db") @@ -116,6 +112,9 @@ (d/transact conn {:tx-data entities}) (throw (ex-info "Invalid snippet entity" {:entities entities}))))) +(def create-snippets + (wrap-snippet-return put-snippets)) + ;; read (defn- get-snippet-by-slug-from-db "Get a single snippet by its slug." diff --git a/src/snippets/main.clj b/src/snippets/main.clj index cce0890..e167b83 100644 --- a/src/snippets/main.clj +++ b/src/snippets/main.clj @@ -1,20 +1,9 @@ (ns snippets.main (:require [snippets.infra.api :as api] - [clojure.core.server] - [snippets.infra.db2 :refer [start-up-check]] - [taoensso.telemere :as t]) + [snippets.infra.db2 :refer [start-up-check]]) (:gen-class)) -(defn start-repl-server [] - (let [settings {:port 5555 :host "0.0.0.0"}] - (clojure.core.server/start-server - (merge - {:name "repl" - :accept 'clojure.core.server/repl} settings)) - (t/log! {:level :info, :data {:settings settings}} "Starting repl server"))) - (defn -main [] (start-up-check) - (start-repl-server) (api/run-server)) diff --git a/src/snippets/use_cases/view.clj b/src/snippets/use_cases/view.clj index 2c58764..5d7a936 100644 --- a/src/snippets/use_cases/view.clj +++ b/src/snippets/use_cases/view.clj @@ -15,8 +15,6 @@ (let [limit (:limit options) skip (:skip options)] (->> (db/list-snippets) - (sort-by :pub-date) - (reverse) (drop skip) (take limit) (map serialize-snippet)))))