@ucdjs/env
v0.2.0
Published
[![npm version][npm-version-src]][npm-version-href] [![npm downloads][npm-downloads-src]][npm-downloads-href]
Downloads
48
Readme
@ucdjs/env
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-nullableLicense
Published under MIT License.
