New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

config-zod

Package Overview
Dependencies
Maintainers
0
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install
Package was removed
Sorry, it seems this package was removed from the registry

config-zod

A zod-based configuration library.

unpublished
latest
npmnpm
Version
1.1.0
Version published
Maintainers
0
Created
Source

Installation

npm install zod-config

Basic usage

Import ZodConfig:

import { ZodConfig } from 'zod-config';

Create a new ZodConfig instance. You can provide a schema directly, or define a callback function that uses the exposed zod variable to create a new config:

// Define your own schema from scratch:
import z from 'zod';
const config = new ZodConfig({
    schema: {
        host: { schema: z.string(), env: 'HOST' },
        port: { schema: z.coerce.number(), env: 'PORT' },
    },
});

// Define a schema using the provided zod variable:
const config = new ZodConfig({
    schema: (z) => ({
        host: { schema: z.string(), env: 'HOST' },
        port: { schema: z.coerce.number(), env: 'PORT' },
    }),
});

Then load your config. Most likely you'll want to provide a relative path to your config json file:

await config.load('./config.prod.json');

When this is done, your config variables will be exposed and can be retrieved as such:

config.get('host');
config.get('port');

FAQs

Package last updated on 20 Oct 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts