Socket
Socket
Sign inDemoInstall

@confconf/confconf-typebox

Package Overview
Dependencies
10
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    @confconf/confconf-typebox

Integrates @confconf/confconf with @sinclair/typebox


Version published
Weekly downloads
68
increased by151.85%
Maintainers
1
Install size
1.58 MB
Created
Weekly downloads
 

Readme

Source

confconf-typebox

Integrates @confconf/confconf with @sinclair/typebox.

Install

npm i --save @confconf/confconf-typebox @sinclair/typebox

Usage

import { confconf, envConfig } from "@confconf/confconf-typebox";
import { Static, Type } from "@sinclair/typebox";

// Define a schema
const configSchema = Type.Object({
  port: Type.Number(),
  db: Type.Object({
    host: Type.String(),
    name: Type.String(),
  }),
});

type Config = Static<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