From f80c48e67910fdaa7c2b4e4b78e5df3fa4a1de25 Mon Sep 17 00:00:00 2001 From: Andrey Antukh Date: Tue, 15 Mar 2016 23:00:57 +0200 Subject: [PATCH] Add compile time defined url variable for easy config the api url. --- scripts/build.clj | 2 ++ scripts/figwheel.clj | 2 ++ src/uxbox/repo/auth.cljs | 2 +- src/uxbox/repo/core.cljs | 3 +-- src/uxbox/repo/projects.cljs | 8 ++++---- 5 files changed, 10 insertions(+), 7 deletions(-) diff --git a/scripts/build.clj b/scripts/build.clj index facbd3ef0..64146298f 100644 --- a/scripts/build.clj +++ b/scripts/build.clj @@ -14,6 +14,8 @@ :output-dir "out" :parallel-build false :optimizations :none + :closure-defines {"uxbox.repo.core.url" + "https://test.uxbox.io/api"} :language-in :ecmascript5 :language-out :ecmascript5 :target :nodejs diff --git a/scripts/figwheel.clj b/scripts/figwheel.clj index ef94ba2e2..4ac2401e0 100644 --- a/scripts/figwheel.clj +++ b/scripts/figwheel.clj @@ -16,6 +16,8 @@ :asset-path "js" :parallel-build false :optimizations :none + :closure-defines {"uxbox.repo.core.url" + "https://test.uxbox.io/api"} :warnings {:ns-var-clash false} :pretty-print true :language-in :ecmascript5 diff --git a/src/uxbox/repo/auth.cljs b/src/uxbox/repo/auth.cljs index 199f79e7c..6c35a22c8 100644 --- a/src/uxbox/repo/auth.cljs +++ b/src/uxbox/repo/auth.cljs @@ -20,7 +20,7 @@ (defn- request-token [params] - (urc/req! {:url (str urc/+uri+ "/auth/token") + (urc/req! {:url (str urc/url "/auth/token") :method :post :auth false :body params})) diff --git a/src/uxbox/repo/core.cljs b/src/uxbox/repo/core.cljs index 1cb7a781c..63e64ef7b 100644 --- a/src/uxbox/repo/core.cljs +++ b/src/uxbox/repo/core.cljs @@ -15,8 +15,7 @@ [uxbox.transit :as t] [uxbox.state :as ust])) -(def ^:private ^:const +uri+ - "http://127.0.0.1:5050/api") +(goog-define url "http://127.0.0.1:5050/api") (def ^:private +storage+ local-storage) diff --git a/src/uxbox/repo/projects.cljs b/src/uxbox/repo/projects.cljs index 05411a1cb..dc07d8fee 100644 --- a/src/uxbox/repo/projects.cljs +++ b/src/uxbox/repo/projects.cljs @@ -20,22 +20,22 @@ (defmethod urc/-do :fetch/projects [type data] - (urc/req! {:url (str urc/+uri+ "/projects") :method :get})) + (urc/req! {:url (str urc/url "/projects") :method :get})) (defmethod urc/-do :fetch/pages [type data] - (urc/req! {:url (str urc/+uri+ "/pages") :method :get})) + (urc/req! {:url (str urc/url "/pages") :method :get})) (defmethod urc/-do :create/page [type {:keys [id] :as data}] - (let [params {:url (str urc/+uri+ "/pages") + (let [params {:url (str urc/url "/pages") :method :post :body data}] (urc/req! params))) (defmethod urc/-do :update/page [type {:keys [id] :as data}] - (let [params {:url (str urc/+uri+ "/pages/" id) + (let [params {:url (str urc/url "/pages/" id) :method :put :body data}] (urc/req! params)))