Set goog.DEBUG and only check schema in development

This commit is contained in:
Rohit Aggarwal 2016-05-14 17:07:15 +01:00
parent 20296f0cc6
commit a2bd81b1d4
3 changed files with 12 additions and 6 deletions

View File

@ -11,11 +11,13 @@
(defn check-and-throw (defn check-and-throw
"throw an exception if db doesn't match the schema." "throw an exception if db doesn't match the schema."
[a-schema db] [a-schema db]
(if-let [problems (s/check a-schema db)] (when-let [problems (s/check a-schema db)]
(throw (js/Error. (str "schema check failed: " problems))))) (throw (js/Error. (str "schema check failed: " problems)))))
(def validate-schema-mw (def validate-schema-mw
(after (partial check-and-throw schema))) (if goog.DEBUG
(after (partial check-and-throw schema))
[]))
;; -- Handlers -------------------------------------------------------------- ;; -- Handlers --------------------------------------------------------------

View File

@ -11,11 +11,13 @@
(defn check-and-throw (defn check-and-throw
"throw an exception if db doesn't match the schema." "throw an exception if db doesn't match the schema."
[a-schema db] [a-schema db]
(if-let [problems (s/check a-schema db)] (when-let [problems (s/check a-schema db)]
(throw (js/Error. (str "schema check failed: " problems))))) (throw (js/Error. (str "schema check failed: " problems)))))
(def validate-schema-mw (def validate-schema-mw
(after (partial check-and-throw schema))) (if goog.DEBUG
(after (partial check-and-throw schema))
[]))
;; -- Handlers -------------------------------------------------------------- ;; -- Handlers --------------------------------------------------------------

View File

@ -35,12 +35,14 @@
:output-dir "target/ios" :output-dir "target/ios"
:static-fns true :static-fns true
:optimize-constants true :optimize-constants true
:optimizations :simple}} :optimizations :simple
:closure-defines {"goog.DEBUG" false}}}
:android {:source-paths ["src" "env/prod"] :android {:source-paths ["src" "env/prod"]
:compiler {:output-to "index.android.js" :compiler {:output-to "index.android.js"
:main "env.android.main" :main "env.android.main"
:output-dir "target/android" :output-dir "target/android"
:static-fns true :static-fns true
:optimize-constants true :optimize-constants true
:optimizations :simple}}}} :optimizations :simple
:closure-defines {"goog.DEBUG" false}}}}}
}}) }})