-
Notifications
You must be signed in to change notification settings - Fork 0
/
system.clj
22 lines (18 loc) · 946 Bytes
/
system.clj
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
(ns clj-restaurants.system
(:require [com.stuartsierra.component :refer [system-map using]]
[clj-restaurants.datasource :as datasource]
[clj-restaurants.migrations :as migrations]
[clj-restaurants.server :as server]
[clj-restaurants.service :as service]
[clj-restaurants.cli :as cli]))
(defn build-system [{{:keys[creds migrations]} :db}]
(system-map
:datasource (datasource/map->Datasource {:config creds})
:migrations (using (migrations/map->Migrations {:config migrations}) [:datasource])
:service (using (service/map->RestaurantService {}) [:datasource :migrations])))
(defn build-cli-system [config]
(merge (build-system config)
{:cli (using (cli/map->CLI {}) [:service])}))
(defn build-server [{:keys [server] :as config}]
(merge (build-system config)
{:server (using (server/map->Server {:config server}) [:service])}))