{"id":18930098,"url":"https://github.com/labd/node-enviconf","last_synced_at":"2026-03-16T18:30:20.133Z","repository":{"id":172386432,"uuid":"648495080","full_name":"labd/node-enviconf","owner":"labd","description":"Node.js package for reading environment variables","archived":false,"fork":false,"pushed_at":"2025-01-08T16:18:51.000Z","size":181,"stargazers_count":0,"open_issues_count":2,"forks_count":0,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-01-08T17:37:50.253Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/labd.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-06-02T05:30:31.000Z","updated_at":"2023-07-18T05:59:47.000Z","dependencies_parsed_at":"2023-12-17T10:43:06.272Z","dependency_job_id":null,"html_url":"https://github.com/labd/node-enviconf","commit_stats":null,"previous_names":["labd/node-enviconf"],"tags_count":10,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/labd%2Fnode-enviconf","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/labd%2Fnode-enviconf/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/labd%2Fnode-enviconf/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/labd%2Fnode-enviconf/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/labd","download_url":"https://codeload.github.com/labd/node-enviconf/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":239927825,"owners_count":19719835,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-08T11:36:32.246Z","updated_at":"2026-03-16T18:30:20.076Z","avatar_url":"https://github.com/labd.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# @labdigital/enviconf\n\nA simple configuration library that loads configuration from environment\nvariables and provides a simple interface to access them.\n\nInspired by https://github.com/caarlos0/env\n\n\n## Example\n\n### Without decorators\n```ts\n\nimport { BaseConfig, EnviConfig, envfield } from \"@labdigital/enviconf\";\n\nclass SampleConfig extends BaseConfig {\n\t/** The port number to listen on */\n\treadonly HTTP_PORT: number = 4000\n\n\tconfig(): EnviConfig {\n\t\treturn {\n\t\t\tHTTP_PORT: envfield.number({\n\t\t\t\t// optional, defaults to false. Sets empty value if no env variable is set\n\t\t\t\toptional: true,\n\n\t\t\t\t// optional, defaults to false. Unsets the env variable after reading\n\t\t\t\tunset: true,\n\n\t\t\t\t// optional, env variable to read the value from, defaults to the property name\n\t\t\t\tenvName: \"MY_HTTP_PORT\",\n\n\t\t\t\t// optional, defaults to undefined. Allows setting a custom validator, should\n\t\t\t\t// throw an error if the value is invalid\n\t\t\t\tvalidator:  (value: number) =\u003e value \u003e 0,\n\t\t\t}),\n\t\t}\n\t}\n}\nconst config = SampleConfig.load()\n\nconfig.HTTP_PORT === 4000\n```\n\n\n### With decorators\n```ts\n\nimport { BaseConfig, envprop } from \"@labdigital/enviconf\";\n\nclass SampleConfig extends BaseConfig {\n  @envprop.string()\n  public readonly MY_STRING_VARIABLE: string = \"default value\";\n\n  @envprop.number()\n  public readonly MY_NUMBER_VARIABLE: number = 123;\n\n  // Read JSON values\n  @envprop.object()\n  public readonly MY_OBJECT_VALUE: object = { foo: \"bar\" };\n\n  @envprop.number({\n    // optional, defaults to false. Sets empty value if no env variable is set\n    optional: true,\n\n    // optional, defaults to false. Unsets the env variable after reading\n    unset: true,\n\n    // optional, env variable to read the value from, defaults to the property name\n    envName: \"MY_OTHER_ENV_VARIABLE\",\n\n    // optional, defaults to \", \". Allows setting a custom separator for array values\n    envSeparator: \", \",\n\n    // optional, defaults to undefined. Allows setting a custom validator, should\n    // throw an error if the value is invalid\n    validator:  (value: number) =\u003e value \u003e 0,\n  })\n  public readonly ALL_OPTIONS: number = 123;\n}\n\nconst config = SampleConfig.load({\n  // optional, path to the .env values, defaults to \".env\"\n  path: \".env\",\n\n  // optional, indicates if a .env file should be read, defaults to true\n  loadEnv: true,\n\n  // optional, if set, will be used as prefix for all env variables while\n  // falling back to the original name if the prefixed variable is not set\n  envPrefix: \"MY_APP_\",\n})\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flabd%2Fnode-enviconf","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flabd%2Fnode-enviconf","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flabd%2Fnode-enviconf/lists"}