From 9901f0a52b10d037193887de2fca82a1f5eb8661 Mon Sep 17 00:00:00 2001 From: Andrey Antukh Date: Wed, 3 Jun 2020 10:50:05 +0200 Subject: [PATCH] :sparkles: Remove backend-uri from all the codebase. --- backend/src/uxbox/config.clj | 17 ++++++++--------- backend/src/uxbox/http/auth/google.clj | 7 +++++-- docker/devenv/files/nginx.conf | 4 ++-- frontend/gulpfile.js | 5 ----- frontend/src/uxbox/config.cljs | 4 +--- frontend/src/uxbox/main/repo.cljs | 10 +++++----- frontend/src/uxbox/main/worker.cljs | 4 ++-- frontend/src/uxbox/util/websockets.cljs | 2 +- frontend/src/uxbox/worker.cljs | 4 ++-- frontend/src/uxbox/worker/thumbnails.cljs | 2 +- manage.sh | 1 - 11 files changed, 27 insertions(+), 33 deletions(-) diff --git a/backend/src/uxbox/config.clj b/backend/src/uxbox/config.clj index ac541b922..3440049c3 100644 --- a/backend/src/uxbox/config.clj +++ b/backend/src/uxbox/config.clj @@ -5,18 +5,18 @@ ;; This Source Code Form is "Incompatible With Secondary Licenses", as ;; defined by the Mozilla Public License, v. 2.0. ;; -;; Copyright (c) 2017-2020 Andrey Antukh +;; Copyright (c) 2020 UXBOX Labs SL (ns uxbox.config "A configuration management." (:require - [clojure.tools.logging :as log] [clojure.spec.alpha :as s] - [uxbox.common.spec :as us] + [clojure.tools.logging :as log] [cuerdas.core :as str] [environ.core :refer [env]] [mount.core :refer [defstate]] [uxbox.common.exceptions :as ex] + [uxbox.common.spec :as us] [uxbox.util.time :as tm])) (def defaults @@ -26,14 +26,13 @@ :database-username "uxbox" :database-password "uxbox" - :public-uri "http://localhost:3449" - :backend-uri "http://localhost:6060" - - :redis-uri "redis://redis/0" :media-directory "resources/public/media" :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-reply-to "no-reply@example.com" diff --git a/backend/src/uxbox/http/auth/google.clj b/backend/src/uxbox/http/auth/google.clj index 7ca6891f5..25c7b9107 100644 --- a/backend/src/uxbox/http/auth/google.clj +++ b/backend/src/uxbox/http/auth/google.clj @@ -2,7 +2,10 @@ ;; 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) 2019 Andrey Antukh +;; 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 (:require @@ -27,7 +30,7 @@ (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")))) (defn- get-access-token diff --git a/docker/devenv/files/nginx.conf b/docker/devenv/files/nginx.conf index 7732fb64c..3e43202de 100644 --- a/docker/devenv/files/nginx.conf +++ b/docker/devenv/files/nginx.conf @@ -85,11 +85,11 @@ http { } location /media { - alias /var/www/app/media; + alias /home/uxbox/uxbox/backend/resources/public/media; } location /static { - alias /var/www/app/backend/resources/public/static; + alias /home/uxbox/uxbox/backend/resources/public/static; } } } diff --git a/frontend/gulpfile.js b/frontend/gulpfile.js index 404bc4444..bc8bf37d4 100644 --- a/frontend/gulpfile.js +++ b/frontend/gulpfile.js @@ -99,7 +99,6 @@ function readLocales() { function readConfig(data) { const googleClientID = process.env.UXBOX_GOOGLE_CLIENT_ID; const publicURI = process.env.UXBOX_PUBLIC_URI; - const backendURI = process.env.UXBOX_BACKEND_URI; const demoWarn = process.env.UXBOX_DEMO_WARNING; const deployDate = process.env.UXBOX_DEPLOY_DATE; const deployCommit = process.env.UXBOX_DEPLOY_COMMIT; @@ -116,10 +115,6 @@ function readConfig(data) { cfg.publicURI = publicURI; } - if (backendURI !== undefined) { - cfg.backendURI = backendURI; - } - if (deployDate !== undefined) { cfg.deployDate = deployDate; } diff --git a/frontend/src/uxbox/config.cljs b/frontend/src/uxbox/config.cljs index 7b1ef9543..9bf89b08a 100644 --- a/frontend/src/uxbox/config.cljs +++ b/frontend/src/uxbox/config.cljs @@ -12,13 +12,11 @@ (this-as global (let [config (obj/get global "uxboxConfig") - puri (obj/get config "publicURI" "http://localhost:3449") - buri (obj/get config "backendURI" "http://localhost:3449") + puri (obj/get config "publicURI" "http://localhost:3449/") gcid (obj/get config "googleClientID" true) warn (obj/get config "demoWarning" true)] (def default-language "en") (def demo-warning warn) - (def backend-uri buri) (def google-client-id gcid) (def public-uri puri) (def default-theme "default"))) diff --git a/frontend/src/uxbox/main/repo.cljs b/frontend/src/uxbox/main/repo.cljs index 03c58e69c..19718ce76 100644 --- a/frontend/src/uxbox/main/repo.cljs +++ b/frontend/src/uxbox/main/repo.cljs @@ -29,13 +29,13 @@ (defn send-query! [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}) (rx/mapcat handle-response)))) (defn send-mutation! [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}) (rx/mapcat handle-response)))) @@ -64,7 +64,7 @@ (defmethod mutation :login-with-google [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}) (rx/mapcat handle-response)))) @@ -94,13 +94,13 @@ (defmethod mutation :login [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}) (rx/mapcat handle-response)))) (defmethod mutation :logout [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}) (rx/mapcat handle-response)))) diff --git a/frontend/src/uxbox/main/worker.cljs b/frontend/src/uxbox/main/worker.cljs index b8bde0c1b..e3f951da8 100644 --- a/frontend/src/uxbox/main/worker.cljs +++ b/frontend/src/uxbox/main/worker.cljs @@ -23,8 +23,8 @@ (defonce instance (when (not= *target* "nodejs") (let [uri (Uri. cfg/public-uri)] - (.setPath uri "js/worker.js") - (.setParameterValue uri "backendURI" cfg/backend-uri) + (.setPath uri "/js/worker.js") + (.setParameterValue uri "publicURI" cfg/public-uri) (uw/init (.toString uri) on-error)))) (defn ask! diff --git a/frontend/src/uxbox/util/websockets.cljs b/frontend/src/uxbox/util/websockets.cljs index 28d981f14..3a0e0f96c 100644 --- a/frontend/src/uxbox/util/websockets.cljs +++ b/frontend/src/uxbox/util/websockets.cljs @@ -27,7 +27,7 @@ (defn uri ([path] (uri path {})) ([path params] - (let [uri (.parse Uri cfg/backend-uri)] + (let [uri (.parse Uri cfg/public-uri)] (.setPath uri path) (if (= (.getScheme uri) "http") (.setScheme uri "ws") diff --git a/frontend/src/uxbox/worker.cljs b/frontend/src/uxbox/worker.cljs index ba1651c69..8726a6168 100644 --- a/frontend/src/uxbox/worker.cljs +++ b/frontend/src/uxbox/worker.cljs @@ -30,8 +30,8 @@ (this-as global (let [location (obj/get global "location") uri (Uri. (obj/get location "href")) - buri (.getParameterValue uri "backendURI")] - (swap! impl/config assoc :backend-uri buri))) + puri (.getParameterValue uri "publicURI")] + (swap! impl/config assoc :public-uri puri))) ;; --- Messages Handling diff --git a/frontend/src/uxbox/worker/thumbnails.cljs b/frontend/src/uxbox/worker/thumbnails.cljs index 74af40212..43d7da701 100644 --- a/frontend/src/uxbox/worker/thumbnails.cljs +++ b/frontend/src/uxbox/worker/thumbnails.cljs @@ -33,7 +33,7 @@ (defn- request-page [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")] (p/create (fn [resolve reject] diff --git a/manage.sh b/manage.sh index 3cffc2f76..4d5139d21 100755 --- a/manage.sh +++ b/manage.sh @@ -56,7 +56,6 @@ function build-frontend { --mount source=${HOME}/.m2,type=bind,target=/home/uxbox/.m2 \ -w /home/uxbox/uxbox/frontend \ -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_DEMO_WARNING=${UXBOX_DEMO_WARNING} \ -e UXBOX_DEPLOY_DATE=${UXBOX_DEPLOY_DATE} \