{"id":23174220,"url":"https://github.com/coursedesign/conev","last_synced_at":"2026-05-09T15:22:01.719Z","repository":{"id":37820464,"uuid":"248219652","full_name":"CourseDesign/conev","owner":"CourseDesign","description":"Conev is a module that build environment variables from a source into config.","archived":false,"fork":false,"pushed_at":"2023-01-16T10:06:42.000Z","size":28,"stargazers_count":1,"open_issues_count":6,"forks_count":2,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-02-10T08:51:29.306Z","etag":null,"topics":["conev","configuration","environment","npm","npm-package"],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/conev","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/CourseDesign.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-03-18T12:00:38.000Z","updated_at":"2023-01-31T17:59:40.000Z","dependencies_parsed_at":"2023-02-01T02:30:21.263Z","dependency_job_id":null,"html_url":"https://github.com/CourseDesign/conev","commit_stats":null,"previous_names":["kdpark0723/conev"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CourseDesign%2Fconev","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CourseDesign%2Fconev/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CourseDesign%2Fconev/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CourseDesign%2Fconev/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/CourseDesign","download_url":"https://codeload.github.com/CourseDesign/conev/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247268503,"owners_count":20911147,"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":["conev","configuration","environment","npm","npm-package"],"created_at":"2024-12-18T05:19:38.099Z","updated_at":"2026-05-09T15:22:01.653Z","avatar_url":"https://github.com/CourseDesign.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# conev\n\nConev is a module that build environment variables from a `source` into `config`. Storing configuration in the environment separate from code is based on [The Twelve-Factor App](http://12factor.net/config) methodology.\n\n![](https://img.shields.io/npm/dm/conev.png?style=flat-square)\n\n​    \n\n## Install\n\n```shell\n# with npm \nnpm install conev\n \n# or with Yarn \nyarn add conev\n```\n\n​    \n\n## Usage\n\nGet ConfigBuilder from conev and one or more Sources to use. In this example, the built-in JsonSource is used.\n\n```typescript\nimport { ConfigBuilder, JsonSource } from 'conev';\n```\n\nAnd create Source and set up.\n\n```typescript\nconst jsonSource = new JsonSource();\n\njsonSource    \n    .setConfig('basic', basic) // basic is JSON\n    .setConfig('dev', dev) // dev is JSON\n    .setConfig('prd', prd); // prd is JSON\n```\n\nCreate ConfigBuilder and set Environment, add source. (highest priority is added first).\n\n```typescript\nconst builder = new ConfigBuilder();\n\nbuilder\n    .setEnv('dev', 'basic')\n    .addSource(jsonSource);\n```\n\nBuild configuration\n\n```typescript\nconst config = await builder.build().refresh(); // This is the result of combining dev and basic.\n```\n\nUse configuration\n\n```typescript\nconfig.get() // The whole configuration created comes out\nconfig.get('a.b.c'); // Is same as config.get().a.b.c\n```\n\n​    \n\n## Config Builder\n\n```typescript\nclass ConfigBuilder {\n    setEnv(...env: string[]): ConfigBuilder;\n    addEnv(...env: string[]): ConfigBuilder;\n    addSource(source: Source, priority?: number): ConfigBuilder;\n\n    build(): Config;\n}\n```\n\n`ConfigBuilder` takes a configuration from the source and creates a new configuration according to the environment. `Env` and `Source` have priority. If priority is not defined, highest priority is added first.\n\n​    \n\n## Config\n\n```typescript\nclass Config {\n    constructor(sources: Source[], env: string[]);\n    \n    setEnv(...env: string[]): Config;\n    addEnv(...env: string[]): Config;\n    addSource(source: Source, priority?: number): Config;\n    \n    refresh(): Promise\u003cConfig\u003e;\n    validate(): void;\n    \n    get(key?: string): object;\n    set(key: string, value: any): void;\n}\n```\n\n`config` is a container for configuration. `config` is provided by creating a new configuration from the configuration and environment obtained from ` source`.\n\n​    \n\n## Source\n\n```typescript\ninterface Source {\n    export(): Promise\u003cMap\u003cstring, object\u003e\u003e;\n}\n```\n\n`Source` defines the source from which to get the configuration. Map is returned as the result value of `export`. The key of this map is environment and the value is the configuration when environment.\n\n​    \n\n## Json Source\n\n```typescript\nclass JsonSource {\n    constructor(map?: Map\u003cstring, object\u003e);\n    setConfig(env: string, ...values: object[]): JsonSource\n    addConfig(env: string, ...values: object[]): JsonSource;\n    removeConfig(env: string): JsonSource;\n    export(): Promise\u003cMap\u003cstring, object\u003e\u003e;\n}\n\n```\n\n`JsonSource` defines the source from JSON. Use `setConfig` to add a configuration for a new environment or ` removeConfig` to delete a configuration. Map is returned as the result value of `export`. The key of this map is environment and the value is the configuration when environment.\n\n​    \n\n## Json File Source\n\n```typescript\nclass JsonFileSource {\n    constructor(fileMap?: Map\u003cstring, string\u003e);\n    setConfig(env: string, ...filenames: string[]): JsonFileSource;\n    addConfig(env: string, ...filename: string[]): JsonFileSource;\n    removeConfig(env: string): JsonFileSource;\n    export(): Promise\u003cMap\u003cstring, object\u003e\u003e;\n}\n```\n\n`JsonFileSource` defines the source from JSON file. Use `setConfig` to add a configuration for a new environment or ` removeConfig` to delete a configuration. Map is returned as the result value of `export`. The key of this map is environment and the value is the configuration when environment.\n\n​    \n\n## Expansion\n\nIt can be extended by defining a new `Source`.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcoursedesign%2Fconev","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcoursedesign%2Fconev","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcoursedesign%2Fconev/lists"}