From d90bd2b84a7693e3b46e680a7316c6f229efc84c Mon Sep 17 00:00:00 2001 From: Joe Carstairs <65492573+Sycamost@users.noreply.github.com> Date: Mon, 7 Aug 2023 21:11:19 +0100 Subject: Ungitignores api build output --- api/_env.js | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 api/_env.js (limited to 'api/_env.js') diff --git a/api/_env.js b/api/_env.js new file mode 100644 index 0000000..409a6df --- /dev/null +++ b/api/_env.js @@ -0,0 +1,33 @@ +"use strict"; +var __importDefault = (this && this.__importDefault) || function (mod) { + return (mod && mod.__esModule) ? mod : { "default": mod }; +}; +Object.defineProperty(exports, "__esModule", { value: true }); +var path_1 = __importDefault(require("path")); +var dotenv_1 = __importDefault(require("dotenv")); +// Parsing the env file. +dotenv_1.default.config({ path: path_1.default.resolve(__dirname, '../.env') }); +var ENV = { + PAYPAL_LIVE_CLIENT_ID: 1, + PAYPAL_LIVE_SECRET: 1, + PAYPAL_SANDBOX_CLIENT_ID: 1, + PAYPAL_SANDBOX_SECRET: 1, + ENVIRONMENT: 1, +}; +var env = process.env; +var sanitisedEnvEntries = Object.keys(ENV) + .map(function (key) { + var value = env[key]; + if (!value) { + throw new Error("Environment not configured correctly. ".concat(key, " was not defined.")); + } + if (key === 'ENVIRONMENT') { + if (!['dev', 'prod'].includes(value)) { + throw new Error("\n Environment not configured correctly. ".concat(key, " must be\n either 'dev' or 'prod', but '").concat(value, "' was provided.\n ")); + } + } + return [key, value]; +}); +var sanitisedEnv = Object.fromEntries(sanitisedEnvEntries); +exports.default = sanitisedEnv; +//# sourceMappingURL=_env.js.map \ No newline at end of file -- cgit v1.2.3