New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@soluzioni-futura/config-component

Package Overview
Dependencies
Maintainers
6
Versions
22
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@soluzioni-futura/config-component

## Quick start

4.1.1
latest
Source
npm
Version published
Weekly downloads
11
-67.65%
Maintainers
6
Weekly downloads
 
Created
Source

config-component

Quick start

Install the package

npm i @soluzioni-futura/config-component

Usage

Simple setup example

import ConfigComponent, { ProcessEnvConfigDriver } from "@soluzioni-futura/config-component"

type ConfigState = {
  SECRET: string
}

const config = new ConfigComponent<ConfigState>([
  new ProcessEnvConfigDriver()
])

await config.fetch()
console.log(config.state.SECRET)

With validation schema

import ConfigComponent, { ProcessEnvDriver } from "@soluzioni-futura/config-component"

type ConfigState = {
  SECRET: string
}

const config = new ConfigComponent<ConfigState>([
  new ProcessEnvDriver(),
  validationSchema: {
    type: "object",
    additionalProperties: true,
    properties: {
      SECRET: { type: "string" }
    },
    required: ["SECRET"]
  }
])

await config.fetch()
console.log(config.state.SECRET)

Complete setup example

import ConfigComponent, { ProcessEnvDriver, SSMConfigDriver } from "@soluzioni-futura/config-component"

const { NODE_ENV = "local" } = process.env

const validationSchema = {
  type: "object",
  additionalProperties: true,
  properties: {
    SECRET: { type: "string" }
  },
  required: ["SECRET"]
}

const drivers = ["staging", "production"].includes(NODE_ENV) ?
  [
    new SSMConfigDriver({
      keys: ["ENV"],
      prefix: `/secrets/${NODE_ENV}`
      ssm: new SSM({
        region: "eu-west-1"
      })
    })
  ] : [
    new ProcessEnvDriver()
  ]

const config = new ConfigComponent(drivers, validationSchema)

await config.fetch()

Keywords

openapi

FAQs

Package last updated on 29 Jun 2023

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