{"id":32118912,"url":"https://github.com/ymonb1291/cfg","last_synced_at":"2026-02-19T08:01:17.758Z","repository":{"id":62421540,"uuid":"282912331","full_name":"ymonb1291/cfg","owner":"ymonb1291","description":"Configuration handler for deno with support for .env and scopes","archived":false,"fork":false,"pushed_at":"2021-06-18T15:16:29.000Z","size":87,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-10-20T17:50:57.523Z","etag":null,"topics":["cfg","configuration","deno","dotenv"],"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/ymonb1291.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-07-27T13:51:31.000Z","updated_at":"2021-06-18T15:16:31.000Z","dependencies_parsed_at":"2022-11-01T17:32:09.860Z","dependency_job_id":null,"html_url":"https://github.com/ymonb1291/cfg","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"purl":"pkg:github/ymonb1291/cfg","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ymonb1291%2Fcfg","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ymonb1291%2Fcfg/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ymonb1291%2Fcfg/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ymonb1291%2Fcfg/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ymonb1291","download_url":"https://codeload.github.com/ymonb1291/cfg/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ymonb1291%2Fcfg/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29608152,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-19T06:47:36.664Z","status":"ssl_error","status_checked_at":"2026-02-19T06:45:47.551Z","response_time":117,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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":["cfg","configuration","deno","dotenv"],"created_at":"2025-10-20T17:46:41.481Z","updated_at":"2026-02-19T08:01:17.751Z","avatar_url":"https://github.com/ymonb1291.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Cfg\n\n![ci](https://github.com/ymonb1291/cfg/workflows/ci/badge.svg)\n![GitHub release (latest by date including pre-releases)](https://img.shields.io/github/v/release/ymonb1291/cfg?include_prereleases)\n![GitHub code size in bytes](https://img.shields.io/github/languages/code-size/ymonb1291/cfg?style=flat-square)\n[![deno doc](https://doc.deno.land/badge.svg)](https://doc.deno.land/https/deno.land/x/cfg/mod.ts)\n![GitHub](https://img.shields.io/github/license/ymonb1291/cfg?style=flat-square)\n\n[![nest badge](https://nest.land/badge.svg)](https://nest.land/package/cfg)\n\nConfiguration handler for **Deno** with support for `.env` and `scopes`.\n\nSome features require access to the file system and the environment. Please run\nyour project with the flags `--allow-read` and `--allow-env`.\n\n# Getting started\n\nImport the latest release.\n\n```\n// From Deno.land\nimport { Cfg } from \"https://deno.land/x/cfg/mod.ts\";\n// From Nest.land\nimport { Cfg } from \"https://x.nest.land/cfg/mod.ts\";\n// From Denopkg\nimport { Cfg } from \"https://denopkg.com/ymonb1291/cfg/mod.ts\";\n// From Github\nimport { Cfg } from \"https://raw.githubusercontent.com/ymonb1291/cfg/master/mod.ts\";\n```\n\nCreate and import the configuration\n\n```\n// Create\nconst myConfig = {fruit: \"Orange\"};\n// Import\nconst cfg = Cfg\u003ctypeof myConfig\u003e([myConfig]);\n```\n\nAccess properties\n\n```\nconsole.log(cfg.get(\"fruit\")); // -\u003e \"Orange\"\n```\n\n# Cfg function\n\n`Cfg()` is an overloaded function with the following signature:\n\n```\nfunction Cfg\u003cConf, Env\u003e(): Config\u003cConf, Env\u003e;\nfunction Cfg\u003cConf, Env\u003e(scope: string): Config\u003cConf, Env\u003e;\nfunction Cfg\u003cConf, Env\u003e(load: Source[]): Config\u003cConf, Env\u003e;\nfunction Cfg\u003cConf, Env\u003e(scope: string, load: Source[]): Config\u003cConf, Env\u003e;\nfunction Cfg\u003cConf, Env\u003e(options: Options): Config\u003cConf, Env\u003e;\n```\n\n### Calling `Cfg()` without argument\n\nCalling `Cfg()` without argument is used to access the `Config` registered on\nthe default scope. If the default scope has not been initialized, an\n`UnknownScopeError` is thrown.\n\n### Calling `Cfg()` with a scope\n\nCalling `Cfg(scope: string)` is used to access the `Config` registered on a\nnon-default scope. If the scope has not been initialized, an `UnknownScopeError`\nis thrown.\n\n### Calling `Cfg()` with sources\n\nCalling `Cfg(load: Source[])` is used to register a `Config` on the default\nscope. If the default scope has already been registed, a `ScopeOverwriteError`\nis thrown.\n\n### Calling `Cfg()` with a scope and sources\n\nCalling `Cfg(scope: string, load: Source[])` is used to register a `Config` on a\nnon-default scope. If the scope has already been registed, a\n`ScopeOverwriteError` is thrown.\n\n### Calling `Cfg()` with options\n\nCalling `Cfg(options: Options)` is used to register a `Config` with an option\nobject. Initialization with `Options` is typically used if you want to use an\n`.env` file. If the scope has already been registed, a `ScopeOverwriteError` is\nthrown.\n\n# Persistance \u0026 scopes\n\nAll configurations are persistant, they are stored by `Cfg` in the background\nand can be accessed from anywhere in your application. They are not private and\ncan be accessed by other modules.\n\nScopes are like namespaces. They allow the developper to segregate\nconfigurations. When developping a module, you should use scopes!\n\n# Methods\n\n## Cfg.prototype.get(...props: string[])\n\nThis method returns the configuration or one of its properties. Don't forget the\ntype parameters when calling `Cfg()` or you might have errors.\n\n`Cfg.prototype.get()` allows up to 4 parameters.\n\n## Cfg.prototype.getp(path: string)\n\nThis method returns the configuration just like `Config.prototype.get()`. But it\naccepts a path as parameter with the syntax `a.b.c` or `a[b][c]`. This method\nwill always return a value with type unknown. Type parameters are not required\nwhen using `getp()`\n\n## Cfg.prototype.env(prop: string)\n\n`Config.prototype.env()` is similar to `Config.prototype.get()` except that it\naccepts only one parameter and returns environment variables.\n\n# Options\n\nThe `Option` interfaces describes an object that can be used to configure `Cfg`.\n\n```\ninterface Options {\n  env?: boolean | EnvOptions;\n  load?: Source | Source[];\n  scope?: string | symbol;\n}\n```\n\n| Property | Type                  | Default           | Description                                                                            |\n| -------- | --------------------- | ----------------- | -------------------------------------------------------------------------------------- |\n| `env`    | boolean \\| EnvOptions | false             | Allows to use `.env` files                                                             |\n| `load`   | Source \\| Source[]    | []                | Specifies the configurations to be loaded. Can be objects, functions or external files |\n| `scope`  | string                | Symbol(\"DEFAULT\") | Specifies the scope                                                                    |\n\nThe `EnvOptions` interface describes the configuration for `.env` files.\n\n```\ninterface EnvOptions {\n  export?: boolean;\n  infer?: boolean;\n  load?: string | Conf | (string | Conf)[]\n  safe?: boolean;\n}\n```\n\n| Property | Type                                 | Default | Description                                                                                                                   |\n| -------- | ------------------------------------ | ------- | ----------------------------------------------------------------------------------------------------------------------------- |\n| `export` | boolean                              | false   | All key/value pairs will be exported to `Deno.env`                                                                            |\n| `infer`  | boolean                              | false   | By default, all values are string. When `true`, the parser will try to convert numbers and booleans to their primitive types. |\n| `load`   | string \\| Conf \\| (string \\| Conf)[] | \".env\"  | Specifies the path to the `.env` file(s) to be loaded.                                                                        |\n| `safe`   | boolean                              | true    | If `export` is enabled, this option will prevent overwriting in ``Deno.env`                                                   |\n\n# Contributions\n\nPRs are welcome!\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fymonb1291%2Fcfg","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fymonb1291%2Fcfg","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fymonb1291%2Fcfg/lists"}