Skip to content

Commit

Permalink
fix: db configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
thelissimus committed Dec 29, 2023
1 parent 6ea7407 commit d1493b1
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 6 deletions.
12 changes: 7 additions & 5 deletions resources/config/backend.edn
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,15 @@
:test 8081}
:db #profile {:default
{:dbtype "postgresql"
:dbname "challenge"
:dbname #env DB_NAME
:host #env DB_HOST
:username "postgres"
:password #or [#env DB_PASSWORD ""]}
:port #long #env DB_PORT
:username #env DB_USERNAME
:password #env DB_PASSWORD}
:test
{:dbtype "postgresql"
:dbname "challenge_test"
:host #env DB_TEST_HOST
:host "localhost"
:port 5432
:username "postgres"
:password #or [#env DB_TEST_PASSWORD ""]}}}
:password "postgres"}}}
3 changes: 2 additions & 1 deletion src/challenge/backend/config.clj
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,11 @@
(s/def :db/dbtype #{"postgresql"})
(s/def :db/dbname ::ne-string)
(s/def :db/host ::ne-string)
(s/def :db/port ::port)
(s/def :db/username ::ne-string)
(s/def :db/password string?)
(s/def ::db
(s/keys :req-un [:db/dbtype :db/dbname :db/host :db/username :db/password]))
(s/keys :req-un [:db/dbtype :db/dbname :db/host :db/port :db/username :db/password]))

(s/def ::config
(s/keys :req-un [::port ::db]))
2 changes: 2 additions & 0 deletions src/challenge/backend/core.clj
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
(ns challenge.backend.core
(:gen-class)
(:require
[mount.core :as mount]
[org.httpkit.server :refer [run-server]]
[taoensso.timbre :refer [info infof]]
[challenge.backend.deps :refer [configuration]]
[challenge.backend.server :as server]))

(defn -main [& _]
(mount/start)
(info "Connected to database")
(infof "Running server on http://localhost:%d" (:port configuration))
(run-server server/app {:port (:port configuration)}))

0 comments on commit d1493b1

Please sign in to comment.