Remove backend-uri from all the codebase.

This commit is contained in:
Andrey Antukh 2020-06-03 10:50:05 +02:00
parent e1ae3da41e
commit 9901f0a52b
11 changed files with 27 additions and 33 deletions

View file

@ -5,18 +5,18 @@
;; This Source Code Form is "Incompatible With Secondary Licenses", as ;; This Source Code Form is "Incompatible With Secondary Licenses", as
;; defined by the Mozilla Public License, v. 2.0. ;; defined by the Mozilla Public License, v. 2.0.
;; ;;
;; Copyright (c) 2017-2020 Andrey Antukh <niwi@niwi.nz> ;; Copyright (c) 2020 UXBOX Labs SL
(ns uxbox.config (ns uxbox.config
"A configuration management." "A configuration management."
(:require (:require
[clojure.tools.logging :as log]
[clojure.spec.alpha :as s] [clojure.spec.alpha :as s]
[uxbox.common.spec :as us] [clojure.tools.logging :as log]
[cuerdas.core :as str] [cuerdas.core :as str]
[environ.core :refer [env]] [environ.core :refer [env]]
[mount.core :refer [defstate]] [mount.core :refer [defstate]]
[uxbox.common.exceptions :as ex] [uxbox.common.exceptions :as ex]
[uxbox.common.spec :as us]
[uxbox.util.time :as tm])) [uxbox.util.time :as tm]))
(def defaults (def defaults
@ -26,14 +26,13 @@
:database-username "uxbox" :database-username "uxbox"
:database-password "uxbox" :database-password "uxbox"
:public-uri "http://localhost:3449"
:backend-uri "http://localhost:6060"
:redis-uri "redis://redis/0"
:media-directory "resources/public/media" :media-directory "resources/public/media"
:assets-directory "resources/public/static" :assets-directory "resources/public/static"
:media-uri "http://localhost:6060/media"
:assets-uri "http://localhost:6060/static" :public-uri "http://localhost:3449/"
:redis-uri "redis://redis/0"
:media-uri "http://localhost:3449/media/"
:assets-uri "http://localhost:3449/static/"
:sendmail-backend "console" :sendmail-backend "console"
:sendmail-reply-to "no-reply@example.com" :sendmail-reply-to "no-reply@example.com"

View file

@ -2,7 +2,10 @@
;; License, v. 2.0. If a copy of the MPL was not distributed with this ;; 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/. ;; file, You can obtain one at http://mozilla.org/MPL/2.0/.
;; ;;
;; Copyright (c) 2019 Andrey Antukh <niwi@niwi.nz> ;; This Source Code Form is "Incompatible With Secondary Licenses", as
;; defined by the Mozilla Public License, v. 2.0.
;;
;; Copyright (c) 2020 UXBOX Labs SL
(ns uxbox.http.auth.google (ns uxbox.http.auth.google
(:require (:require
@ -27,7 +30,7 @@
(defn- build-redirect-url (defn- build-redirect-url
[] []
(let [public (uri/uri (:backend-uri cfg/config))] (let [public (uri/uri (:public-uri cfg/config))]
(str (assoc public :path "/api/oauth/google/callback")))) (str (assoc public :path "/api/oauth/google/callback"))))
(defn- get-access-token (defn- get-access-token

View file

@ -85,11 +85,11 @@ http {
} }
location /media { location /media {
alias /var/www/app/media; alias /home/uxbox/uxbox/backend/resources/public/media;
} }
location /static { location /static {
alias /var/www/app/backend/resources/public/static; alias /home/uxbox/uxbox/backend/resources/public/static;
} }
} }
} }

View file

@ -99,7 +99,6 @@ function readLocales() {
function readConfig(data) { function readConfig(data) {
const googleClientID = process.env.UXBOX_GOOGLE_CLIENT_ID; const googleClientID = process.env.UXBOX_GOOGLE_CLIENT_ID;
const publicURI = process.env.UXBOX_PUBLIC_URI; const publicURI = process.env.UXBOX_PUBLIC_URI;
const backendURI = process.env.UXBOX_BACKEND_URI;
const demoWarn = process.env.UXBOX_DEMO_WARNING; const demoWarn = process.env.UXBOX_DEMO_WARNING;
const deployDate = process.env.UXBOX_DEPLOY_DATE; const deployDate = process.env.UXBOX_DEPLOY_DATE;
const deployCommit = process.env.UXBOX_DEPLOY_COMMIT; const deployCommit = process.env.UXBOX_DEPLOY_COMMIT;
@ -116,10 +115,6 @@ function readConfig(data) {
cfg.publicURI = publicURI; cfg.publicURI = publicURI;
} }
if (backendURI !== undefined) {
cfg.backendURI = backendURI;
}
if (deployDate !== undefined) { if (deployDate !== undefined) {
cfg.deployDate = deployDate; cfg.deployDate = deployDate;
} }

View file

@ -12,13 +12,11 @@
(this-as global (this-as global
(let [config (obj/get global "uxboxConfig") (let [config (obj/get global "uxboxConfig")
puri (obj/get config "publicURI" "http://localhost:3449") puri (obj/get config "publicURI" "http://localhost:3449/")
buri (obj/get config "backendURI" "http://localhost:3449")
gcid (obj/get config "googleClientID" true) gcid (obj/get config "googleClientID" true)
warn (obj/get config "demoWarning" true)] warn (obj/get config "demoWarning" true)]
(def default-language "en") (def default-language "en")
(def demo-warning warn) (def demo-warning warn)
(def backend-uri buri)
(def google-client-id gcid) (def google-client-id gcid)
(def public-uri puri) (def public-uri puri)
(def default-theme "default"))) (def default-theme "default")))

View file

@ -29,13 +29,13 @@
(defn send-query! (defn send-query!
[id params] [id params]
(let [uri (str cfg/backend-uri "/api/w/query/" (name id))] (let [uri (str cfg/public-uri "/api/w/query/" (name id))]
(->> (http/send! {:method :get :uri uri :query params}) (->> (http/send! {:method :get :uri uri :query params})
(rx/mapcat handle-response)))) (rx/mapcat handle-response))))
(defn send-mutation! (defn send-mutation!
[id params] [id params]
(let [uri (str cfg/backend-uri "/api/w/mutation/" (name id))] (let [uri (str cfg/public-uri "/api/w/mutation/" (name id))]
(->> (http/send! {:method :post :uri uri :body params}) (->> (http/send! {:method :post :uri uri :body params})
(rx/mapcat handle-response)))) (rx/mapcat handle-response))))
@ -64,7 +64,7 @@
(defmethod mutation :login-with-google (defmethod mutation :login-with-google
[id params] [id params]
(let [uri (str cfg/backend-uri "/api/oauth/google")] (let [uri (str cfg/public-uri "/api/oauth/google")]
(->> (http/send! {:method :post :uri uri}) (->> (http/send! {:method :post :uri uri})
(rx/mapcat handle-response)))) (rx/mapcat handle-response))))
@ -94,13 +94,13 @@
(defmethod mutation :login (defmethod mutation :login
[id params] [id params]
(let [uri (str cfg/backend-uri "/api/login")] (let [uri (str cfg/public-uri "/api/login")]
(->> (http/send! {:method :post :uri uri :body params}) (->> (http/send! {:method :post :uri uri :body params})
(rx/mapcat handle-response)))) (rx/mapcat handle-response))))
(defmethod mutation :logout (defmethod mutation :logout
[id params] [id params]
(let [uri (str cfg/backend-uri "/api/logout")] (let [uri (str cfg/public-uri "/api/logout")]
(->> (http/send! {:method :post :uri uri :body params}) (->> (http/send! {:method :post :uri uri :body params})
(rx/mapcat handle-response)))) (rx/mapcat handle-response))))

View file

@ -23,8 +23,8 @@
(defonce instance (defonce instance
(when (not= *target* "nodejs") (when (not= *target* "nodejs")
(let [uri (Uri. cfg/public-uri)] (let [uri (Uri. cfg/public-uri)]
(.setPath uri "js/worker.js") (.setPath uri "/js/worker.js")
(.setParameterValue uri "backendURI" cfg/backend-uri) (.setParameterValue uri "publicURI" cfg/public-uri)
(uw/init (.toString uri) on-error)))) (uw/init (.toString uri) on-error))))
(defn ask! (defn ask!

View file

@ -27,7 +27,7 @@
(defn uri (defn uri
([path] (uri path {})) ([path] (uri path {}))
([path params] ([path params]
(let [uri (.parse Uri cfg/backend-uri)] (let [uri (.parse Uri cfg/public-uri)]
(.setPath uri path) (.setPath uri path)
(if (= (.getScheme uri) "http") (if (= (.getScheme uri) "http")
(.setScheme uri "ws") (.setScheme uri "ws")

View file

@ -30,8 +30,8 @@
(this-as global (this-as global
(let [location (obj/get global "location") (let [location (obj/get global "location")
uri (Uri. (obj/get location "href")) uri (Uri. (obj/get location "href"))
buri (.getParameterValue uri "backendURI")] puri (.getParameterValue uri "publicURI")]
(swap! impl/config assoc :backend-uri buri))) (swap! impl/config assoc :public-uri puri)))
;; --- Messages Handling ;; --- Messages Handling

View file

@ -33,7 +33,7 @@
(defn- request-page (defn- request-page
[id] [id]
(let [uri (get @impl/config :backend-uri "http://localhost:6060") (let [uri (get @impl/config :public-uri "http://localhost:3449/")
uri (str uri "/api/w/query/page")] uri (str uri "/api/w/query/page")]
(p/create (p/create
(fn [resolve reject] (fn [resolve reject]

View file

@ -56,7 +56,6 @@ function build-frontend {
--mount source=${HOME}/.m2,type=bind,target=/home/uxbox/.m2 \ --mount source=${HOME}/.m2,type=bind,target=/home/uxbox/.m2 \
-w /home/uxbox/uxbox/frontend \ -w /home/uxbox/uxbox/frontend \
-e UXBOX_PUBLIC_URI=${UXBOX_PUBLIC_URI} \ -e UXBOX_PUBLIC_URI=${UXBOX_PUBLIC_URI} \
-e UXBOX_BACKEND_URI=${UXBOX_BACKEND_URI} \
-e UXBOX_GOOGLE_CLIENT_ID=${UXBOX_GOOGLE_CLIENT_ID} \ -e UXBOX_GOOGLE_CLIENT_ID=${UXBOX_GOOGLE_CLIENT_ID} \
-e UXBOX_DEMO_WARNING=${UXBOX_DEMO_WARNING} \ -e UXBOX_DEMO_WARNING=${UXBOX_DEMO_WARNING} \
-e UXBOX_DEPLOY_DATE=${UXBOX_DEPLOY_DATE} \ -e UXBOX_DEPLOY_DATE=${UXBOX_DEPLOY_DATE} \