Update database.configs to get values from ENV
This commit is contained in:
parent
955b1e75c1
commit
114ab582b5
@ -69,9 +69,12 @@ The app is designed to be run within Kubernetes or within a Docker container, as
|
|||||||
|OWL_SRV_LISTEN|0.0.0.0|NO|Web Server Listen Address|
|
|OWL_SRV_LISTEN|0.0.0.0|NO|Web Server Listen Address|
|
||||||
|OWL_DB_USER||YES|Database Username|
|
|OWL_DB_USER||YES|Database Username|
|
||||||
|OWL_DB_PASS||YES|Database Password|
|
|OWL_DB_PASS||YES|Database Password|
|
||||||
|OWL_DB_NAME||YES|Database Name|
|
|OWL_DB_NAME|owlboard|NO|Database Name|
|
||||||
|OWL_DB_PORT||YES|Database Server Port|
|
|OWL_DB_PORT|3306|NO|Database Server Port|
|
||||||
|OWL_DB_HOST||YES|Database Server Host|
|
|OWL_DB_HOST|database|NO|Database Server Host|
|
||||||
|OWL_LDB_KEY||YES|National Rail LDBWS API Key|
|
|OWL_LDB_KEY||YES|National Rail LDBWS API Key|
|
||||||
|OWL_LDB_SVKEY||NO|National Rail LDBSVWS API Key|
|
|OWL_LDB_SVKEY||NO|National Rail LDBSVWS API Key|
|
||||||
|
|OWL_LDB_CORPUSUSER||YES|Network Rail CORPUS API Username|
|
||||||
|
|OWL_LDB_CORPUSPASS||YES|Network Rail CORPUS API Password|
|
||||||
|
|
||||||
|
In the case that OWL_LDB_SVKEY is not available, staff versions of departure board, etc. will not be available.
|
@ -1,15 +1,54 @@
|
|||||||
OWL_DB_USER
|
function getUser(){
|
||||||
OWL_DB_PASS
|
if (process.env.OWL_DB_USER){
|
||||||
OWL_DB_NAME
|
var dbUser = process.env.OWL_DB_USER;
|
||||||
OWL_DB_PORT
|
} else {
|
||||||
OWL_DB_HOST
|
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 = {
|
const database = {
|
||||||
user: 'owlboard',
|
user: getUser(),
|
||||||
password: 'owlboard',
|
password: getPass(),
|
||||||
database: 'owlboard',
|
database: getName(),
|
||||||
port: 8460,
|
port: getPort(),
|
||||||
host: 'localhost'
|
host: getHost()
|
||||||
};
|
};
|
||||||
|
|
||||||
module.exports = database;
|
module.exports = database;
|
Reference in New Issue
Block a user