Socket
Socket
Sign inDemoInstall

nestjs-zod-config

Package Overview
Dependencies
14
Maintainers
1
Versions
9
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 2.3.0 to 2.4.0

42

dist/zod-config-static.js
"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.ZodConfigStatic = void 0;
// Load the .env file into the process.env
const dotenv_1 = require("dotenv");
const process = __importStar(require("process"));
/**

@@ -13,5 +36,16 @@ * This class is the base class for this module.

constructor(schema) {
// Load .env file before parsing process.env
(0, dotenv_1.config)();
this.config = schema.parse(process.env);
let configObject = process.env;
// Override the environment variables obtained from `process.env`
// with the ones obtained from the `.env` file, if it exists.
try {
configObject = {
...configObject,
// TODO: allow the consumer to pass the path to the `.env` file
...(0, dotenv_1.config)().parsed,
};
}
catch (error) {
throw new Error(`Error parsing .env file`);
}
this.config = schema.parse(configObject);
}

@@ -18,0 +52,0 @@ get(key) {

2

package.json
{
"name": "nestjs-zod-config",
"version": "2.3.0",
"version": "2.4.0",
"description": "NestJS module to load, type and validate configuration using Zod",

@@ -5,0 +5,0 @@ "keywords": [

@@ -140,2 +140,2 @@ # NestJS Zod Config

Normally you will do: `z.coerce.boolean()` but this will also coerce the string `'false'` to `true`.
So instead we use this function to only allow the string `'false'` to be coerced to `false` and everything else will throw an error.
So instead we use this function to only allow `'false'` or `false` to be coerced to `false`, `'true'` or `true` to `true` and everything else will throw an error.
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc