Skip to content

Latest commit

 

History

History

README.md

@ucdjs/env

npm version npm downloads

Runtime constants and environment helpers shared across the UCD.js workspace.

Installation

npm install @ucdjs/env

Note

Full documentation is available at docs.ucdjs.dev/api-reference/utilities/env.

Exports

Base URL Constants

These resolve from the matching process.env variable when set, otherwise fall back to the defaults below.

Export Default
UCDJS_API_BASE_URL https://api.ucdjs.dev
UCDJS_DOCS_URL https://docs.ucdjs.dev
UCDJS_STORE_BASE_URL https://ucd-store.ucdjs.dev
DEFAULT_USER_AGENT ucdjs.dev (https://ucdjs.dev)

HTTP Stat Headers

Header name constants used in UCD HTTP responses to surface file/directory metadata.

Export Header name
UCD_STAT_TYPE_HEADER X-UCD-Stat-Type
UCD_STAT_SIZE_HEADER X-UCD-Stat-Size
UCD_STAT_CHILDREN_HEADER X-UCD-Stat-Children
UCD_STAT_CHILDREN_FILES_HEADER X-UCD-Stat-Children-Files
UCD_STAT_CHILDREN_DIRS_HEADER X-UCD-Stat-Children-Dirs

Utilities

requiredEnv(env, requiredKeys)

Validates that the specified keys are present in an environment object and returns it with narrowed types. Throws if any key is missing.

import { requiredEnv } from "@ucdjs/env";

const env = requiredEnv(rawEnv, ["DATABASE_URL", "API_KEY"]);
// env.DATABASE_URL and env.API_KEY are guaranteed non-nullable

License

Published under MIT License.