🚀 DAY 5 OF LAUNCH WEEK: Introducing Socket Firewall Enterprise.Learn more →
Socket
Book a DemoInstallSign in
Socket

@apoyo/process

Package Overview
Dependencies
Maintainers
1
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@apoyo/process

Utils focused around the current process

latest
Source
npmnpm
Version
0.3.0
Version published
Maintainers
1
Created
Source

Apoyo - Process

npm version

Installation

Install peer dependencies: npm install @apoyo/std @apoyo/decoders @apoyo/ioc

Install package: npm install @apoyo/process

Documentation

This package contains various utils and injectable focused on data from the current node process. This includes:

  • Reading and validating NODE_ENV, with a preset of supported values ('development', 'staging', 'production' and 'test').

  • Reading, validating and parsing environment variables from process.env and .env files.

  • Reading application information from the package.json.

  • etc...

The full documentation will be made available soon.

Example

Getting the current application environment

Process.$appEnv

Note: If no NODE_ENV is specified, the environment will be set to production.

Getting and/or mocking the environment variables

Process.$env

Note: This injectable will automatically load and include variables from matching .env files. See dotenv-flow for more information.

Note: The process.env variable is not overriden!

Validating and parsing your environment variables

Env.define creates a new injectable that parses the env with the given schema. This returns a fully typed object.

const $dbEnv = Env.define({
  DB_HOST: TextDecoder.string,
  DB_PORT: IntegerDecoder.int
})

const $dbConfig = Implementation.create([$dbEnv], (env) => {
  return {
    host: env.DB_HOST,
    port: env.DB_PORT
  }
})

Note: There is no need to manually load the environment, as this injectable depends on Process.$env, which will automatically load the .env files.

License

This project is licensed under the MIT License - see the LICENSE file for details.

Keywords

utils

FAQs

Package last updated on 30 Nov 2022

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