diff options
| author | Joe Carstairs <65492573+Sycamost@users.noreply.github.com> | 2023-08-07 21:11:19 +0100 |
|---|---|---|
| committer | Joe Carstairs <65492573+Sycamost@users.noreply.github.com> | 2023-08-07 21:12:25 +0100 |
| commit | d90bd2b84a7693e3b46e680a7316c6f229efc84c (patch) | |
| tree | 9f55412947b2319f5ca8cd1ff1f3e58cb7417386 /api/_env.js | |
| parent | 84adcb14af7a0e13549f1977a2a5690e978fcf57 (diff) | |
Ungitignores api build output
Diffstat (limited to 'api/_env.js')
| -rw-r--r-- | api/_env.js | 33 |
1 files changed, 33 insertions, 0 deletions
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 |
