Check environment variables before node.js app starts
Sanity.js is a small library that checks a list of environment variables are set and meet your format requirements before your app starts up.
Here's a quick snippet of how it could be used:
var sanity = require('sanity');
sanity.check(['USER', 'MACHTYPE', 'INVISIBLE_FRIENDS', 'AREA_51']);
// Output if INVISIBLE_FRIENDS and AREA_51 are undefined
ERROR: Required settings are not correct!
INVISIBLE_FRIENDS: undefined
AREA_51: undefined
Full documentation (and tests!) are a the sanity repo.
Written by Adam Yanalunas
Related protips
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Node
Authors
Did you know?
JavaScript on a page runs with the privileges of that origin. One altered library, tag manager, or snippet can read inputs, change what people see, and call your APIs as the user.
Security insights from Cside
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#