2018-02-07 22:16:39 +03:00
|
|
|
"use strict";
|
|
|
|
|
2018-02-08 19:22:05 +03:00
|
|
|
/* eslint-disable no-process-env */
|
|
|
|
|
2018-04-24 17:12:36 +03:00
|
|
|
const path = require("path");
|
|
|
|
require("dotenv").load({path: path.join(__dirname, ".env")});
|
2018-02-07 22:16:39 +03:00
|
|
|
|
|
|
|
const kEnvironmentVariables = [
|
2018-06-01 01:55:19 +03:00
|
|
|
"NODE_ENV",
|
2018-02-07 22:16:39 +03:00
|
|
|
"SERVER_URL",
|
|
|
|
"PORT",
|
|
|
|
"COOKIE_SECRET",
|
|
|
|
"SMTP_HOST",
|
|
|
|
"SMTP_PORT",
|
|
|
|
"SMTP_USERNAME",
|
|
|
|
"SMTP_PASSWORD",
|
|
|
|
"OAUTH_AUTHORIZATION_URI",
|
|
|
|
"OAUTH_TOKEN_URI",
|
|
|
|
"OAUTH_PROFILE_URI",
|
|
|
|
"OAUTH_CLIENT_ID",
|
|
|
|
"OAUTH_CLIENT_SECRET",
|
2018-05-22 21:34:41 +03:00
|
|
|
"HIBP_STAGE_API_ROOT",
|
|
|
|
"HIBP_STAGE_API_TOKEN",
|
2018-05-15 22:33:22 +03:00
|
|
|
"HIBP_STUB_API_ROOT",
|
2018-02-06 01:06:05 +03:00
|
|
|
"HIBP_API_ROOT",
|
2018-02-13 15:02:51 +03:00
|
|
|
"HIBP_API_TOKEN",
|
2018-03-08 19:26:43 +03:00
|
|
|
"DATABASE_URL",
|
2018-02-07 22:16:39 +03:00
|
|
|
];
|
|
|
|
|
2018-03-05 16:53:53 +03:00
|
|
|
const AppConstants = { };
|
|
|
|
|
|
|
|
for (const v of kEnvironmentVariables) {
|
|
|
|
if (process.env[v] === undefined) {
|
|
|
|
throw new Error(`Required environment variable was not set: ${v}`);
|
|
|
|
}
|
|
|
|
AppConstants[v] = process.env[v];
|
|
|
|
}
|
2018-02-07 22:16:39 +03:00
|
|
|
|
2018-03-03 04:49:32 +03:00
|
|
|
module.exports = Object.freeze(AppConstants);
|