Skip to content

Commit

Permalink
chore: check env vars at startup
Browse files Browse the repository at this point in the history
  • Loading branch information
minademian committed Jan 12, 2024
1 parent b750a60 commit d160269
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
2 changes: 2 additions & 0 deletions apps/api/src/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ const limiter = rateLimit({
// TODO: refactor with a lib that's compatible with both limiter and express
});

config.checkEnvVariables();

app.use(
bodyParser.json({
limit: '8mb',
Expand Down
7 changes: 2 additions & 5 deletions apps/api/src/services/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,9 @@ const ENV_VARS = [
'GOOGLE_CLIENT_ID',
'GOOGLE_CLIENT_SECRET',
'GOOGLE_SPREADSHEET_ID',
'APP_ID',
'APP_SECRET',
'VERIFY_TOKEN',
'APP_URL',
'APP_PORT',
'SESSION_SECRET',
'API_STORE_PREFIX',
];

type Origin = string | boolean | RegExp;
Expand Down Expand Up @@ -69,7 +66,7 @@ const config: Config = {
if (!process.env[key]) {
console.warn('WARNING: Missing the environment variable ' + key);
} else {
if (['APP_URL', 'SHOP_URL'].includes(key)) {
if (['APP_URL'].includes(key)) {
const url: string = process.env[key] as string;
if (!url.startsWith('https://')) {
console.warn(
Expand Down

0 comments on commit d160269

Please sign in to comment.