Clojurescript-node.js mount module for a district server, that takes care of loading configuration from a file at system start.
Add [district0x/district-server-config "1.5.0-SNAPSHOT"]
into your project.clj
Include [district.server.config]
in your CLJS file, where you use mount/start
.
Warning: district0x modules are still in early stages, therefore API can change in a future.
To see how district server modules play together in real-world app, you can take a look at NameBazaar server folder, where this is deployed in production.
You can pass following args to config module:
:default
Default configuration that will be deep-merged with the one read from a file:env-name
Name of ENV variable that stores path to config file. Default:CONFIG
:file-path
Path to a config file. Default:config.edn
, but won't throw error if doesn't exist
Config file is expected to be in EDN format.
(ns my-district
(:require [mount.core :as mount]
[district.server.config :refer [config]]))
(-> (mount/with-args
{:config {:default {:something 1}
:env-name "DISTRICT_CONFIG"
;; Use one of :env-name or :file-path
:file-path "config.edn"}})
(mount/start))
(println @config)
;; => {:something 1 :some-other-thing 2}
- Build:
npx shadow-cljs compile test-node
- also need to deploy contracts:
npx truffle migrate --network ganache --reset
- Tests:
node out/node-tests.js
To release (happens automatically on CI at merge to master)
- Build:
clj -T:build jar
- Release:
clj -T:build deploy