Import backend code inside the repository.

This commit is contained in:
Andrey Antukh 2016-11-20 20:04:52 +01:00
parent e21798f1ed
commit de57630c14
No known key found for this signature in database
GPG key ID: 4DFEBCB8316A8B95
113 changed files with 8040 additions and 0 deletions

View file

@ -0,0 +1,92 @@
;; This Source Code Form is subject to the terms of the Mozilla Public
;; License, v. 2.0. If a copy of the MPL was not distributed with this
;; file, You can obtain one at http://mozilla.org/MPL/2.0/.
;;
;; Copyright (c) 2016 Andrey Antukh <niwi@niwi.nz>
(ns uxbox.main
(:require [clojure.tools.namespace.repl :as repl]
[clojure.walk :refer [macroexpand-all]]
[clojure.pprint :refer [pprint]]
[clojure.test :as test]
[clojure.java.io :as io]
[mount.core :as mount]
[buddy.core.codecs :as codecs]
[buddy.core.codecs.base64 :as b64]
[buddy.core.nonce :as nonce]
[uxbox.config :as cfg]
[uxbox.migrations]
[uxbox.db]
[uxbox.frontend]
[uxbox.scheduled-jobs])
(:gen-class))
;; --- Development Stuff
(defn- start
[]
(mount/start))
(defn- start-minimal
[]
(-> (mount/only #{#'uxbox.config/config
#'uxbox.db/datasource
#'uxbox.migrations/migrations})
(mount/start)))
(defn- stop
[]
(mount/stop))
(defn- refresh
[]
(stop)
(repl/refresh))
(defn- refresh-all
[]
(stop)
(repl/refresh-all))
(defn- go
"starts all states defined by defstate"
[]
(start)
:ready)
(defn- reset
[]
(stop)
(repl/refresh :after 'uxbox.main/start))
(defn make-secret
[]
(-> (nonce/random-bytes 64)
(b64/encode true)
(codecs/bytes->str)))
;; --- Entry point (only for uberjar)
(defn test-vars
[& vars]
(repl/refresh)
(test/test-vars
(map (fn [sym]
(require (symbol (namespace sym)))
(resolve sym))
vars)))
(defn test-ns
[ns]
(repl/refresh)
(test/test-ns ns))
(defn test-all
([] (test/run-all-tests #"^uxbox.tests.*"))
([re] (test/run-all-tests re)))
;; --- Entry point (only for uberjar)
(defn -main
[& args]
(mount/start))