Currently there's no explicit check for required environment variables
(e.g. MONGO_URI, JWT_SECRET) at startup — the code relies on try/catch
blocks catching downstream failures instead.
This means if a required var is missing/misconfigured, the error surfaces
later (e.g. a MongoDB connection failure or JWT error) rather than a
clear message pointing to the actual missing variable — which can be
confusing for new contributors during local setup.
Would it be welcome to add a small startup check, e.g.:
const requiredEnvVars = ['MONGO_URI', 'JWT_SECRET'];
requiredEnvVars.forEach((key) => {
if (!process.env[key]) {
console.error(Missing required env variable: ${key});
process.exit(1);
}
});
Happy to open a PR for this if it fits the project's direction.
Currently there's no explicit check for required environment variables
(e.g. MONGO_URI, JWT_SECRET) at startup — the code relies on try/catch
blocks catching downstream failures instead.
This means if a required var is missing/misconfigured, the error surfaces
later (e.g. a MongoDB connection failure or JWT error) rather than a
clear message pointing to the actual missing variable — which can be
confusing for new contributors during local setup.
Would it be welcome to add a small startup check, e.g.:
const requiredEnvVars = ['MONGO_URI', 'JWT_SECRET'];
requiredEnvVars.forEach((key) => {
if (!process.env[key]) {
console.error(
Missing required env variable: ${key});process.exit(1);
}
});
Happy to open a PR for this if it fits the project's direction.