LakshmiSowmya04 / GradLink

Reconnect. Rediscover. Rebuild.
6 stars 4 forks source link

Safe env variable parser for backend-nodejs runtime #10

Open mahabubx7 opened 3 hours ago

mahabubx7 commented 3 hours ago

Safe .env variable parser for backend-nodejs runtime

I would like to propose an idea to implement a safe .env variable parser that can help us to determine if any required variable is missing or given invalid. For development or production, it can be a good way to plug-in .env variables in a safe mode.

We can define something like:

// src/env.js
const { getEnv } = require('./lib/env-parser');

module.exports = {
  env: {
    mongoUri: getEnv('MONGO_URI', ['string', 'required']),
  },
};

Now, we can use registered variables everywhere we need. Also, if we miss any variable (i.e. MONGO_URI) then it will throw an error or we can also give default values as well.

mahabubx7 commented 3 hours ago

@LakshmiSowmya04 If this feature fits well in your consideration then please assign me. I will be glad to have the opportunity to contribute. 🚀 🚀 🚀

LakshmiSowmya04 commented 2 hours ago

You have been assigned ...please go for it @mahabubx7 ...also mention how can someone retrieve this value for backend uses