Implement ENV Vars
This commit is contained in:
parent
9067079756
commit
52b1eda644
12
.vscode/tasks.json
vendored
Normal file
12
.vscode/tasks.json
vendored
Normal file
@ -0,0 +1,12 @@
|
||||
{
|
||||
"version": "2.0.0",
|
||||
"tasks": [
|
||||
{
|
||||
"type": "npm",
|
||||
"script": "start",
|
||||
"problemMatcher": [],
|
||||
"label": "npm: start",
|
||||
"detail": "node app.js"
|
||||
}
|
||||
]
|
||||
}
|
5
app.js
5
app.js
@ -6,7 +6,6 @@
|
||||
|
||||
const express = require('express');
|
||||
const app = express();
|
||||
const config = require('./src/configs/server.configs');
|
||||
const version = require('./src/configs/version.configs');
|
||||
const testRtr = require('./src/routes/test.routes');
|
||||
const listRtr = require('./src/routes/list.routes');
|
||||
@ -35,9 +34,9 @@ app.use('/api/v1/ldb', ldbRtr);
|
||||
app.use('/api/kube', kubeRtr);
|
||||
|
||||
// Start Express
|
||||
app.listen(config.port, config.listen, (error) =>{
|
||||
app.listen(process.env.OWL_SRV_PORT, process.env.OWL_SRV_LISTEN, (error) =>{
|
||||
if(!error) {
|
||||
console.log(`Started server on http://${config.listen}:${config.port}`);
|
||||
console.log(`Started server on http://${process.env.OWL_SRV_LISTEN}:${process.env.OWL_SRV_PORT}`);
|
||||
} else {
|
||||
console.log("Error occurred, server can't start", error);
|
||||
}
|
||||
|
@ -1,54 +0,0 @@
|
||||
function getUser(){
|
||||
if (process.env.OWL_DB_USER){
|
||||
var dbUser = process.env.OWL_DB_USER;
|
||||
} else {
|
||||
var dbUser = "ERR";
|
||||
};
|
||||
return dbUser;
|
||||
}
|
||||
|
||||
function getPass(){
|
||||
if (process.env.OWL_DB_PASS){
|
||||
var dbPass = process.env.OWL_DB_USER;
|
||||
} else {
|
||||
var dbPass = "ERR";
|
||||
};
|
||||
return dbPass;
|
||||
}
|
||||
|
||||
function getName(){
|
||||
if (process.env.OWL_DB_NAME){
|
||||
var dbName = process.env.OWL_DB_NAME;
|
||||
} else {
|
||||
var dbName = "owlboard";
|
||||
};
|
||||
return dbName;
|
||||
}
|
||||
|
||||
function getPort(){
|
||||
if (process.env.OWL_DB_PORT){
|
||||
var dbPort = process.env.OWL_DB_PORT;
|
||||
} else {
|
||||
var dbPort = 3306
|
||||
}
|
||||
return Number(dbPort);
|
||||
}
|
||||
|
||||
function getHost(){
|
||||
if (process.env.OWL_DB_HOST){
|
||||
var dbHost = process.env.OWL_DB_HOST;
|
||||
} else {
|
||||
var dbHost = "database";
|
||||
}
|
||||
return dbHost;
|
||||
}
|
||||
|
||||
const database = {
|
||||
user: getUser(),
|
||||
password: getPass(),
|
||||
database: getName(),
|
||||
port: getPort(),
|
||||
host: getHost()
|
||||
};
|
||||
|
||||
module.exports = database;
|
@ -1,28 +0,0 @@
|
||||
function getPort(){
|
||||
if (process.env.OWL_SRV_PORT){
|
||||
var confPort = process.env.OWL_SRV_PORT;
|
||||
} else {
|
||||
var confPort = 8460;
|
||||
};
|
||||
return Number(confPort);
|
||||
}
|
||||
|
||||
function getListen(){
|
||||
if (process.env.OWL_SRV_LISTEN){
|
||||
var confListen = process.env.OWL_SRV_LISTEN;
|
||||
} else {
|
||||
var confListen = "0.0.0.0"
|
||||
}
|
||||
return confListen;
|
||||
}
|
||||
|
||||
const server = {
|
||||
port: getPort(),
|
||||
listen: getListen()
|
||||
};
|
||||
|
||||
module.exports = {
|
||||
server,
|
||||
getPort,
|
||||
getListen
|
||||
}
|
@ -1,7 +1,12 @@
|
||||
const kube = require('../services/kube.services');
|
||||
|
||||
async function getAlive(req, res, next){
|
||||
res.status("200").send(`{"status":"alive"}`)
|
||||
try {
|
||||
var state = kube.getAlive()
|
||||
res.status((await state).code).send((await state).state)
|
||||
} catch (err) {
|
||||
res.status("503").send({state: "error"})
|
||||
}
|
||||
}
|
||||
|
||||
async function getReady(req, res, next){
|
||||
|
@ -1,7 +1,14 @@
|
||||
// General DB Access aswell as dbInit tests etc.
|
||||
|
||||
const database = require( '../utils/dbinit.utils' )
|
||||
const options = require('../configs/database.confiigs')
|
||||
|
||||
|
||||
const dbUser = process.env.OWL_DB_USER || "owl"
|
||||
const dbPass = process.env.OWL_DB_PASS || ""
|
||||
const dbName = process.env.OWL_DB_NAME || "owlboard"
|
||||
const dbPort = process.env.OWL_DB_PORT || 0
|
||||
const dbHost = process.env.OWL_DB_HOST || "database"
|
||||
|
||||
|
||||
const { Client } = require( 'pg' )
|
||||
|
||||
|
@ -1,7 +1,12 @@
|
||||
async function getAlive(){
|
||||
return {code: 200, state: {state: "alive",noise: "twit-twoo"}}
|
||||
}
|
||||
|
||||
async function getReady(){
|
||||
return "not_implemented";
|
||||
};
|
||||
|
||||
module.exports = {
|
||||
getAlive,
|
||||
getReady
|
||||
}
|
@ -1,8 +1,9 @@
|
||||
const version = require('../configs/version.configs');
|
||||
const corpus = require('../utils/corpus.utils');
|
||||
|
||||
async function get(){
|
||||
// Databse lookup, get list of all stations as per the Python script output
|
||||
return {};
|
||||
return corpus.init();
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
|
Reference in New Issue
Block a user