Skip to content

Missing env variable validation on startup #664

Description

@Tejaswini-35433

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions