一键导入
objectenvy-docs
Documentation site for objectenvy
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
Documentation site for objectenvy
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
基于 SOC 职业分类
Automatically map process.env to strongly-typed, nested config objects with camelCase fields Use when working with config, configuration, env, environment, type-safe, zod, nested, camelcase.
ObjectEnvy monorepo - strongly-typed environment configuration for TypeScript projects
| name | objectenvy-docs |
| description | Documentation site for objectenvy |
Documentation site for objectenvy
process.env into a typed, nested config object at application startup.prefix: 'APP' and strip the prefix from keys.LOG__LEVEL) and want { log: { level } } nesting.env object in tests while keeping the same schema and prefix.objectify + envy)..env file from a config object (e.g., for CI scaffolding or test fixtures).ToEnv<T> for compile-time validation and need the runtime values to match.objectify() → mutate config → envy() → write back to env.concat or concat-unique).envy()..env documentation or scaffolding from TypeScript property names.objectify() uses internally to an individual value.objectify() and need consistent boolean/number parsing.Avoid when:
.required() / .asInt() semantics — use env-var instead.override().env:.objectEnvy instances instead.ToEnv<T> type at compile time — no need to call envy() at runtime.Date, Map, Set, or class instances — envy() serializes them as[object Object] via String().merge() instead.override() calls.override() instead.merge(merge(a, b), c) calls.[a-z] after the underscore.PascalCase output — capitalise the first character of the result separately.toCamelCase(toSnakeCase('apiURL')) yields 'apiUrl','apiURL'.'123' must stay '123') — passcoerce: false to objectify() instead, or handle the type downstream.parseFloat/parseInt are locale-independent but only'1e5') is NOT coerced to a number.PORT_* variable later silently restructures { portNumber } into { port: { number } },SCREAMING_SNAKE_CASE env object when relying on FromEnv types — BECAUSEcoerce: true (the default) if a value looks like a number but must stay a string —'01' becomes 1 (integer parse), losing the leading zero.objectEnvy() — BECAUSE theprocess.env after caching returns stale data.process.env after calling the inner objectify() expecting the result to update —objectEnvy instance across packages that need independent schemas — BECAUSE theenvy() to round-trip arrays of objects faithfully — BECAUSE object items areJSON.stringify-ed then joined; when objectify() re-reads the comma-separated string, itnull or undefined values in the config — BECAUSE envy() silently skipsnull/undefined entries, leaving no env key for them; the round-trip loses those fields.envy() to honour a prefix — BECAUSE it outputs bare SCREAMING_SNAKE_CASE keysAPP_PORT rather than PORT.defaults or config arguments after calling override() — BECAUSE theoverride() to handle class instances or special objects (Date, Map, Set) — BECAUSEtypeof === 'object' and recurses, which may produce unexpected results formerge() to deep-clone the inputs — BECAUSE nested sub-objects are shallow-copied'concat-unique' to deduplicate object items if equality matters beyond JSON serialisation —JSON.stringify for comparison, which is order-sensitive and ignoresundefined values, Date objects, and prototype methods.merge() handles non-plain objects (Map, Set, Date, class instances) correctly —typeof === 'object' and recurses, producing incorrect results fortoCamelCase(toSnakeCase(x)) === x for all inputs — BECAUSE acronym boundariesapiURL → API_URL → apiUrl) collapse consecutive capitals, so the round-trip isgetHTTPSUrl → GET_HTTPS_URL →getHttpsUrl, losing the original casing of consecutive uppercase letters.PORT_NUMBER → PORT__NUMBER (double underscore)_N boundary.coerceValue on values that use commas as decimal separators (e.g., '3,14' in[3, 14] rather than the3.14.'01234') —parseInt('01234', 10) returns 1234.'on'/'off' being coerced to booleans — BECAUSE only true/false/yes/no/y/n'on' stays as the string 'on'.Configuration options for objectify() — controls prefix filtering,
env source, Zod schema validation, camelCase nesting behaviour, and include/exclude patterns.
| Key | Type | Required | Default | Description |
|---|---|---|---|---|
prefix | string | no | — | Filter environment variables by prefix. |
| e.g., "APP" will only include variables starting with "APP_" | ||||
env | EnvLike | no | — | Custom environment object. Defaults to process.env |
schema | `T extends ConfigObject ? ZodObject<any, $strip> | T : never` | no | — |
| Can be either a Zod schema or a plain object with the same structure as your config. | ||||
| Zod schemas will validate, plain objects provide type inference only. | ||||
coerce | boolean | no | — | Whether to automatically coerce values to numbers/booleans |
delimiter | string | no | — | Delimiter used to indicate nesting depth. |
| By default, each underscore creates a new nesting level. | ||||
| Set to '__' to use double underscores for nesting. | ||||
nonNestingPrefixes | string[] | no | — | Prefix segments that should not trigger nesting even when multiple entries share the prefix. |
| For example, keys starting with 'max', 'min', 'is', 'enable', 'disable' will stay flat: | ||||
| MAX_CONNECTIONS, MAX_TIMEOUT -> { maxConnections, maxTimeout } | ||||
| IS_DEBUG, IS_VERBOSE -> { isDebug, isVerbose } | ||||
include | string[] | no | — | Include only environment variables matching these patterns. |
| Matches against the normalized key (after prefix removal, in camelCase). | ||||
| If specified, only variables matching at least one pattern will be included. | ||||
exclude | string[] | no | — | Exclude environment variables matching these patterns. |
| Matches against the normalized key (after prefix removal, in camelCase). | ||||
| Variables matching any pattern will be excluded. |
Options for controlling the merge behaviour of merge() and override().
| Key | Type | Required | Default | Description |
|---|---|---|---|---|
arrayMergeStrategy | ArrayMergeStrategy | no | — | Strategy to apply when both objects contain an array at the same key. |
'replace' — the second (higher-priority) array replaces the first entirely.'concat' — arrays are concatenated, second array appended after the first.'concat-unique' — concatenated with duplicate primitive values removed. |Parsing: objectify, objectEnvy, toCamelCase, coerceValue
Serialization: envy, toSnakeCase
Merging: override, merge
Type Utilities: ConfigObject, ConfigValue, ArrayMergeStrategy, ToEnv, FromEnv, WithPrefix, WithoutPrefix, SchemaToEnv