Commit 3f43d4c6 authored by Vadym Gidulian's avatar Vadym Gidulian

Added `checkEnvironmentVariables` function

parent c2b8c4e0
'use strict';
const grace = require('./grace');
const {createError, logError, logInfo, logWarn} = require('./log');
const {checkEnvironmentVariables} = require('./util');
['MONGODB_URI', 'SEQID_GEN_API'].forEach(varname => {
if (!process.env[varname]) {
logError(`Environment variable ${varname} is not defined!`);
grace.shutdown(1);
}
});
checkEnvironmentVariables('MONGODB_URI', 'SEQID_GEN_API');
const {MongoClient} = require('mongodb');
const SeqidGenApi = require('@gviagroup/seqid-gen-api');
const grace = require('./grace');
const {createError, logError, logInfo, logWarn} = require('./log');
let mongoClient = null;
const seqidGen = new SeqidGenApi(process.env.SEQID_GEN_API);
......
'use strict';
const {shutdown} = require('./grace');
const {logError} = require('./log');
module.exports = {
checkEnvironmentVariables(...varNames) {
for (const varName of varNames) {
if (!process.env[varName]) {
logError(`Environment variable ${varName} is not set!`);
shutdown(1);
}
}
}
};
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment