Work on varTest

This commit is contained in:
Fred Boniface 2022-12-24 10:40:13 +00:00
parent 8361dabcf0
commit c2c04cee12
2 changed files with 34 additions and 0 deletions

9
app.js
View File

@ -22,6 +22,15 @@ const srvPort = process.env.OWL_SRV_PORT || 8460
// Print version number:
console.log(`Starting OwlBoard - App Version: ${version.app} - API versions: ${version.api}`);
// Test for required vars:
// const varTest = require('./src/utils/varTest.utils');
// var startTest = await varTest.varTest();
//console.log("Required Vars Missing:", startTest.missing_required);
//console.log("Desired Vars Missing:", startTest.missing_desired);
// if startTest.pass == false
// console.log("Unable to start, missing required vars")
// exit app
// Express Error Handling:
app.use((err, req, res, next) => {
const statusCode = err.statuscode || 500;

View File

@ -1,2 +1,27 @@
// Checks that all required environment variables are present.
// Returns True or False and offers an object detailing what is missing.
async function varTest(){
var required = {
OWL_LDB_KEY: process.env.OWL_LDB_KEY,
OWL_LDB_CORPUSUSER: process.env.OWL_LDB_CORPUSUSER,
OWL_LDB_CORPUSPASS: process.env.OWL_LDB_CORPUSPASS,
OWL_NOT_USED: process.env.OWL_NOT_USED
}
var desired = {
OWL_DB_PASS: process.env.OWL_DB_PASS
}
// DO NOT LOG CREDENTIALS!!!
// Test that each of required is NOT undefined.
// var pass = true if all okay, false if not.
// Append any missing values to missing_required = []
// Test that each of desired is NOT undefined.
// Append any missing values to missing_desired = []
// Return : {pass: $pass, missong_required = $missing_required, missing_desired = $missing_desired}
}
module.exports = {
varTest
}