Socket
Socket
Sign inDemoInstall

@confconf/confconf-purify

Package Overview
Dependencies
11
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    @confconf/confconf-purify

Integrates @confconf/confconf with purify-ts


Version published
Maintainers
1
Install size
1.58 MB
Created

Readme

Source

confconf-purify

Integrates @confconf/confconf with purify-ts.

Install

npm i --save @confconf/confconf-purify purify-ts

Usage

import { confconf, envConfig } from "@confconf/confconf-purify";
import { Codec, number, string, GetType } from "purify-ts/Codec";

// Define a schema
const configSchema = Codec.interface({
  port: number,
  db: Codec.interface({
    host: string,
    name: string,
  }),
});

type Config = GetType<typeof configSchema>;

// Create the configuration loader and load configuration and validate
// it against the schema
const config = await confconf({
  schema: configSchema,
  providers: [
    // Load from env variables
    envConfig({
      // Map the specifc env variables into a specific structure
      structure: {
        port: "PORT",
        db: {
          host: "DB_HOST",
          name: "DB_NAME",
        },
      },
    }),
  ],
}).loadAndValidate();

Keywords

FAQs

Last updated on 05 Sep 2022

Did you know?

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

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