Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Checking if 3000 port is running #30

Merged
merged 2 commits into from
Mar 15, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
12 changes: 12 additions & 0 deletions frontend/src/boot/axios.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,18 @@ const axiosInstance = axios.create({
baseURL: process.env.BASE_URL
});
const _appendSubdomain = (domain, subdomain) => {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When possible, try not to overload functions with a lot of different steps. Ideally, a function would do only one thing and the name of the function would describe the one thing it does.

// Get the hostname (including port)
const hostname = domain.split("://")[1];

// a domain name contains at least one letter
const hostnameIsDomain = hostname.match(/[a-z]/i);

// skip adding sub-domain to IP
if (!hostnameIsDomain) {
return domain;
}

// If localhost is in domain
if (domain.indexOf("localhost") > -1) {
return domain;
}
Expand Down
11 changes: 11 additions & 0 deletions frontend/src/boot/env-parser.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,16 @@
const DotEnv = require("dotenv");
const execSync = require("child_process").execSync;
let is3000On = false;

try {
is3000On = execSync("lsof -t -i :3000 -s TCP:LISTEN").toString();
} catch (e) {
// not running throws error
}

module.exports = function() {
if (!!is3000On) {
return { ...DotEnv.config().parsed, BASE_URL: "http://127.0.0.1:3000" };
}
return DotEnv.config().parsed;
};