summaryrefslogtreecommitdiff
path: root/src/app/handler.clj
blob: fdf722eb47e2bef17d26dd55cbf95579f27d0c1a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
(ns app.handler
  (:require [app.portmaster :as pm]
            [app.temperature :as temp]
            [castra.middleware :as castra]
            [compojure.core :as c]
            [compojure.route :as route]
            [ring.middleware.defaults :as d]
            [ring.util.response :as response]
            [simpledb.core :as db]))

(c/defroutes app-routes
  (c/GET "/" req (response/content-type (response/resource-response "index.html") "text/html"))
  (route/resources "/" {:root ""}))

(def app
  (-> app-routes
      (castra/wrap-castra {:state-fn (fn [] "ohi")} 'app.api)
      (d/wrap-defaults d/api-defaults)))

(db/init)

(let [{:keys [init port-name username password]} (db/get :portmaster)]
  (when init
    (pm/init port-name username password)))

(let [{:keys [init]} (db/get :temperature)]
  (when init
    (temp/init)))