Update final configurations to use ENV VARs
This commit is contained in:
parent
0572420d19
commit
a8d7c46098
8
app.js
8
app.js
@ -12,6 +12,10 @@ const listRtr = require('./src/routes/list.routes');
|
||||
const ldbRtr = require('./src/routes/ldb.routes');
|
||||
const kubeRtr = require('./src/routes/kube.routes');
|
||||
|
||||
// Set Server Configurations
|
||||
const srvListen = process.env.OWL_SRV_LISTEN || "0.0.0.0"
|
||||
const srvPort = process.env.OWL_SRV_PORT || 8460
|
||||
|
||||
// Print version number:
|
||||
console.log(`Starting OwlBoard - App Version: ${version.app} - API versions: ${version.api}`);
|
||||
|
||||
@ -34,9 +38,9 @@ app.use('/api/v1/ldb', ldbRtr);
|
||||
app.use('/api/kube', kubeRtr);
|
||||
|
||||
// Start Express
|
||||
app.listen(process.env.OWL_SRV_PORT, process.env.OWL_SRV_LISTEN, (error) =>{
|
||||
app.listen(srvPort, srvListen, (error) =>{
|
||||
if(!error) {
|
||||
console.log(`Started server on http://${process.env.OWL_SRV_LISTEN}:${process.env.OWL_SRV_PORT}`);
|
||||
console.log(`Started server on http://${srvListen}:${srvPort}`);
|
||||
} else {
|
||||
console.log("Error occurred, server can't start", error);
|
||||
}
|
||||
|
@ -8,9 +8,11 @@
|
||||
// convertTiploc(TIPLOC) : Exported: Looks up CRS, Name & STANOX for Tiploc
|
||||
|
||||
const ldb = require('ldbs-json')
|
||||
const keys = require('/srv/keys/owlboard/keys.configs')
|
||||
const util = require('../utils/ldb.utils')
|
||||
|
||||
const ldbKey = process.env.OWL_LDB_KEY
|
||||
const ldbsvKey = process.env.OWL_LDB_SVKEY
|
||||
|
||||
async function get(body, id){
|
||||
// Read request body for information on request
|
||||
// Check whether input is CRS or TIPLOC with util.checkInput(input)
|
||||
@ -30,7 +32,7 @@ async function arrDepBoard(CRS){
|
||||
numRows: 10,
|
||||
crs: CRS.toUpperCase()
|
||||
}
|
||||
var api = new ldb(keys.ldb,false)
|
||||
var api = new ldb(ldbKey,false)
|
||||
var reply = await api.call("GetArrDepBoardWithDetails",options)
|
||||
return reply
|
||||
} else if (valid == false) {
|
||||
|
@ -8,10 +8,12 @@
|
||||
// extract(): Extract the CORPUS JSON file from the GZIP file.
|
||||
// clean() : Cleans the CORPUS data, removing unneccesary keys and objects from the data.
|
||||
|
||||
const keys = require('/srv/keys/owlboard/keys.configs')
|
||||
const axios = require('axios')
|
||||
const gz = require('node-gzip')
|
||||
|
||||
const corpusUser = process.env.OWL_LDB_CORPUSUSER
|
||||
const corpusPass = process.env.OWL_LDB_CORPUSPASS
|
||||
|
||||
async function init() {
|
||||
var gzipData = await get()
|
||||
var corpus = await extract(gzipData)
|
||||
@ -20,7 +22,7 @@ async function init() {
|
||||
}
|
||||
|
||||
async function get() {
|
||||
authHead = Buffer.from(`${keys.nr_user}:${keys.nr_pass}`).toString('base64')
|
||||
authHead = Buffer.from(`${corpusUser}:${corpusPass}`).toString('base64')
|
||||
const url = 'https://datafeeds.networkrail.co.uk/ntrod/SupportingFileAuthenticate?type=CORPUS'
|
||||
const options = {
|
||||
method: 'get',
|
||||
|
Reference in New Issue
Block a user