5 ms·
Colossal waste? - have a .json with format [{ name: AUTH_TOKEN, type: String }] (you can add extras like regex match etc) - have a method that goes through al
by poisonborz 3y ago
Colossal waste?
- have a .json with format [{ name: AUTH_TOKEN, type: String }] (you can add extras like regex match etc)
- have a method that goes through all items on startup and checks process.env existence plus the type.
- use this method as a getter method based on name
- search replace all other process.env usage and disable it via linting so that no one can get around the restriction
voila.
Oooor use these libs from other people who had the same idea (I just found them as well)
https://www.npmjs.com/package/envalid https://www.npmjs.com/package/envalid
https://www.npmjs.com/package/env-vars-validator https://www.npmjs.com/package/env-vars-validator