@shipfox/config
v1.2.0
Published
This is a utility library handling configuration used by other packages for [Shipfox](https://www.shipfox.io/) projects.
Downloads
1,109
Keywords
Readme
Shipfox config
This is a utility library handling configuration used by other packages for Shipfox projects.
What it does
Typed, validated environment configuration built on top of envalid.
- createConfig(schema): Validates
process.envagainst your schema and returns a strongly-typed config object. - Re-exports common validators:
str,num,bool,email,host,port,url(fromenvalid). - Fail-fast: Throws at startup if required variables are missing/invalid.
Installation
pnpm add @shipfox/config
# or
yarn add @shipfox/config
# or
npm install @shipfox/configUsage
import { createConfig, str, num, bool } from "@shipfox/config";
const config = createConfig({
NODE_ENV: str({ choices: ["development", "test", "production"] }),
PORT: num({ default: 3000 }),
DEBUG: bool({ default: false }),
});
// Typed access
config.PORT; // number
config.DEBUG; // boolean