Skip to content

Commit

Permalink
29 checking if 3000 port is running before connecting. If running it …
Browse files Browse the repository at this point in the history
…uses that as baseUrl
  • Loading branch information
shailee-m authored and brylie committed Mar 15, 2021
1 parent 39cf179 commit 459ac54
Show file tree
Hide file tree
Showing 5 changed files with 59 additions and 9 deletions.
1 change: 1 addition & 0 deletions frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
"moment-timezone": "0.5.32",
"plotly.js": "^1.55.2",
"quasar": "^1.0.0",
"shelljs": "0.8.4",
"vue-i18n": "^8.20.0",
"webpack": "^5.23.0",
"xlsx": "0.16.7"
Expand Down
12 changes: 3 additions & 9 deletions frontend/quasar.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,11 @@
* This file runs in a Node context (it's NOT transpiled by Babel), so use only
* the ES6 features that are supported by your Node version. https://node.green/
*/
const envParser = require("./src/boot/env-parser");

// Configuration for your app
// https://quasar.dev/quasar-cli/quasar-conf-js
/* eslint-env node */

module.exports = function(/* ctx */) {
module.exports = function() {
return {
// https://quasar.dev/quasar-cli/supporting-ts
supportTS: false,
Expand All @@ -20,6 +18,7 @@ module.exports = function(/* ctx */) {
// --> boot files are part of "main.js"
// https://quasar.dev/quasar-cli/boot-files
boot: ["i18n", "axios"],
target : 'node',

// https://quasar.dev/quasar-cli/quasar-conf-js#Property%3A-css
css: ["app.scss"],
Expand All @@ -28,19 +27,14 @@ module.exports = function(/* ctx */) {
extras: [
"material-icons",
"fontawesome-v5",
// 'eva-icons',
// 'themify',
// 'line-awesome',
// 'roboto-font-latin-ext', // this or either 'roboto-font', NEVER both!

"roboto-font" // optional, you are not bound to it
// 'material-icons', // optional, you are not bound to it
],

// Full list of options: https://quasar.dev/quasar-cli/quasar-conf-js#Property%3A-build
build: {
vueRouterMode: "hash", // available values: 'hash', 'history'
env: envParser(),
env: require("./src/boot/env-parser")(),
// transpile: false,

// Add dependencies for transpiling with Babel (Array of string/regex)
Expand Down
14 changes: 14 additions & 0 deletions frontend/src/boot/axios.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,20 @@ const axiosInstance = axios.create({
baseURL: process.env.BASE_URL
});
const _appendSubdomain = (domain, subdomain) => {
const ip = domain.split("://")[1]
? domain.split("://")[1].split(":")
? domain.split("://")[1].split(":")[0]
: null
: null;

//skip adding sub-domain to ip
if (
/^(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$/.test(
ip
)
) {
return domain;
}
if (domain.indexOf("localhost") > -1) {
return domain;
}
Expand Down
5 changes: 5 additions & 0 deletions frontend/src/boot/env-parser.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
const DotEnv = require("dotenv");
var shell = require("shelljs");
var is3000On = shell.exec("lsof -t -i :3000 -s TCP:LISTEN").stdout;

module.exports = function() {
if (!!is3000On) {
return { ...DotEnv.config().parsed, BASE_URL: "http://127.0.0.1:3000" };
}
return DotEnv.config().parsed;
};
36 changes: 36 additions & 0 deletions frontend/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -7399,6 +7399,11 @@ internal-ip@^4.3.0:
default-gateway "^4.2.0"
ipaddr.js "^1.9.0"

interpret@^1.0.0:
version "1.4.0"
resolved "https://registry.yarnpkg.com/interpret/-/interpret-1.4.0.tgz#665ab8bc4da27a774a40584e812e3e0fa45b1a1e"
integrity sha512-agE4QfB2Lkp9uICn7BAqoscw4SZP9kTE2hxiFI3jBPmXJfdqiahTbUuKGsMoN2GtqL9AxhYioAcVvgsb1HvRbA==

interval-tree-1d@^1.0.1:
version "1.0.3"
resolved "https://registry.yarnpkg.com/interval-tree-1d/-/interval-tree-1d-1.0.3.tgz#8fdbde02b6b2c7dbdead636bcbed8e08710d85c1"
Expand Down Expand Up @@ -7553,6 +7558,13 @@ is-color-stop@^1.0.0:
rgb-regex "^1.0.1"
rgba-regex "^1.0.0"

is-core-module@^2.2.0:
version "2.2.0"
resolved "https://registry.yarnpkg.com/is-core-module/-/is-core-module-2.2.0.tgz#97037ef3d52224d85163f5597b2b63d9afed981a"
integrity sha512-XRAfAdyyY5F5cOXn7hYQDqh2Xmii+DEfIcQGxK/uNwMHhIkPWO0g8msXcbzLe+MpGoR951MlqM/2iIlU4vKDdQ==
dependencies:
has "^1.0.3"

is-data-descriptor@^0.1.4:
version "0.1.4"
resolved "https://registry.yarnpkg.com/is-data-descriptor/-/is-data-descriptor-0.1.4.tgz#0b5ee648388e2c860282e793f1856fec3f301b56"
Expand Down Expand Up @@ -10783,6 +10795,13 @@ readdirp@~3.4.0:
dependencies:
picomatch "^2.2.1"

rechoir@^0.6.2:
version "0.6.2"
resolved "https://registry.yarnpkg.com/rechoir/-/rechoir-0.6.2.tgz#85204b54dba82d5742e28c96756ef43af50e3384"
integrity sha1-hSBLVNuoLVdC4oyWdW70OvUOM4Q=
dependencies:
resolve "^1.1.6"

recursive-readdir@^2.1.0:
version "2.2.2"
resolved "https://registry.yarnpkg.com/recursive-readdir/-/recursive-readdir-2.2.2.tgz#9946fb3274e1628de6e36b2f6714953b4845094f"
Expand Down Expand Up @@ -11096,6 +11115,14 @@ resolve@^1.0.0, resolve@^1.1.5, resolve@^1.10.0, resolve@^1.12.0, resolve@^1.13.
dependencies:
path-parse "^1.0.6"

resolve@^1.1.6:
version "1.20.0"
resolved "https://registry.yarnpkg.com/resolve/-/resolve-1.20.0.tgz#629a013fb3f70755d6f0b7935cc1c2c5378b1975"
integrity sha512-wENBPt4ySzg4ybFQW2TT1zMQucPK95HSh/nq2CFTZVOGut2+pQvSsgtda4d26YrYcr067wjbmzOG8byDPBX63A==
dependencies:
is-core-module "^2.2.0"
path-parse "^1.0.6"

[email protected], responselike@^1.0.2:
version "1.0.2"
resolved "https://registry.yarnpkg.com/responselike/-/responselike-1.0.2.tgz#918720ef3b631c5642be068f15ade5a46f4ba1e7"
Expand Down Expand Up @@ -11637,6 +11664,15 @@ shell-quote@^1.6.1:
resolved "https://registry.yarnpkg.com/shell-quote/-/shell-quote-1.7.2.tgz#67a7d02c76c9da24f99d20808fcaded0e0e04be2"
integrity sha512-mRz/m/JVscCrkMyPqHc/bczi3OQHkLTqXHEFu0zDhK/qfv3UcOA4SVmRCLmos4bhjr9ekVQubj/R7waKapmiQg==

[email protected]:
version "0.8.4"
resolved "https://registry.yarnpkg.com/shelljs/-/shelljs-0.8.4.tgz#de7684feeb767f8716b326078a8a00875890e3c2"
integrity sha512-7gk3UZ9kOfPLIAbslLzyWeGiEqx9e3rxwZM0KE6EL8GlGwjym9Mrlx5/p33bWTu9YG6vcS4MBxYZDHYr5lr8BQ==
dependencies:
glob "^7.0.0"
interpret "^1.0.0"
rechoir "^0.6.2"

signal-exit@^3.0.0, signal-exit@^3.0.2:
version "3.0.3"
resolved "https://registry.yarnpkg.com/signal-exit/-/signal-exit-3.0.3.tgz#a1410c2edd8f077b08b4e253c8eacfcaf057461c"
Expand Down

0 comments on commit 459ac54

Please sign in to comment.