envsafe-lite
Version:
Lightweight, type-safe environment variable parser for Node.js with zero dependencies.
17 lines (16 loc) • 509 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.string = string;
function string(options = {}) {
return {
_type: "string",
parse(key, value) {
if (value === undefined || value === null || value === "") {
if (options.default !== undefined)
return options.default;
throw new Error(`Missing required environment variable: ${key}`);
}
return value;
}
};
}