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