{"id":18612425,"url":"https://github.com/avivcarmis/conf-eager-js","last_synced_at":"2026-05-03T09:34:50.645Z","repository":{"id":57205328,"uuid":"103530258","full_name":"avivcarmis/conf-eager-js","owner":"avivcarmis","description":"Strongly typed eager-initialization configuration library for JavaScript","archived":false,"fork":false,"pushed_at":"2017-10-26T14:55:01.000Z","size":39,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-01-27T15:11:08.614Z","etag":null,"topics":["configuration","eager-loading","javascript","strong-typed","type-safety","typescript"],"latest_commit_sha":null,"homepage":null,"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/avivcarmis.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-09-14T12:37:17.000Z","updated_at":"2017-09-16T00:45:13.000Z","dependencies_parsed_at":"2022-09-18T01:32:25.901Z","dependency_job_id":null,"html_url":"https://github.com/avivcarmis/conf-eager-js","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/avivcarmis%2Fconf-eager-js","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/avivcarmis%2Fconf-eager-js/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/avivcarmis%2Fconf-eager-js/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/avivcarmis%2Fconf-eager-js/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/avivcarmis","download_url":"https://codeload.github.com/avivcarmis/conf-eager-js/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":239402840,"owners_count":19632464,"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":["configuration","eager-loading","javascript","strong-typed","type-safety","typescript"],"created_at":"2024-11-07T03:17:05.616Z","updated_at":"2025-11-02T23:30:26.095Z","avatar_url":"https://github.com/avivcarmis.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# ConfEagerJS\n\n[![ConfEagerJs Build Status at Travis CI](https://api.travis-ci.org/avivcarmis/conf-eager-js.svg?branch=master)](\"https://api.travis-ci.org/avivcarmis/conf-eager-js.svg?branch=master\")\n\nConfEagerJS is an eager, strongly-typed configuration library for JavaScript, designed to maximize runtime safety, while maintaining lightweight, easy integration and dynamic nature.\nMore on the motivation for this project [can be found below](#why \"can be found below\").\n\n## Quick Start\n\nInstallation via NPM:\n\n`$ npm install confeager --save`\n\n\u003e Comparability Note: ConfEagerJS uses [Smoke Screen library](https://www.npmjs.com/package/smoke-screen \"Smoke Screen library\")\nto define and validate object schemas and types at runtime. This requires usage of \nEcmaScript decorators. While EcmaScript doesn't officially support decorators yet, the examples below are implemented in TypeScript, but may also be implemented in any other way that compiles decorators.\n\nConsider a YAML configuration file `config.yaml`:\n```yaml\nhost: 0.0.0.0           # string\nport: 8080              # number\nhttps: false            # boolean\nlogLevel: INFO          # enum\nnestedConfiguration:    # object\n  nestedProperty: 1234\narrayConfiguration:     # array\n  - 1234\n  - 2345\n```\n\nThen a consumer written in TypeScript:\n```typescript\nimport {exposed, PropertyTypes} from \"smoke-screen\";\nimport {ConfEagerSources} from \"confeager\";\n\nenum LogLevel {\n    INFO, WARN, ERROR\n}\n\nclass NestedConfiguration {\n\n    @exposed({type: PropertyTypes.number})\n    readonly nestedProperty: number;\n\n}\n\nclass Configuration {\n\n    @exposed({type: PropertyTypes.string})\n    readonly host: string;\n\n    @exposed({type: PropertyTypes.number})\n    readonly port: number;\n\n    // note the following property, it's called `useHttps` but exposed as `https`:    \n    @exposed({as: \"https\", type: PropertyTypes.number})\n    readonly useHttps: boolean;\n\n    // enum property of enum class LogLevel\n    // valid values may only be `INFO`, `WARN` or `ERROR`\n    @exposed({type: PropertyTypes.enumOf(LogLevel)})\n    readonly logLevel: LogLevel;\n\n    @exposed({type: PropertyTypes.objectOf(NestedConfiguration)})\n    readonly nestedConfiguration: NestedConfiguration;\n\n    @exposed({type: PropertyTypes.arrayOf(PropertyTypes.number)})\n    readonly arrayConfiguration: number[];\n\n    // all other properties are required and their absence\n    // from the source will cause an error on init,\n    // this property is optional and when absent will be\n    // populated with the value \"value\"\n    @exposed({type: PropertyTypes.string, defaultValue: \"value\"})\n    readonly optionalProperty: string;\n\n}\n\n// load config data from a yaml file with a watch interval of\n// 10 milliseconds into a conf eager source.\nconst source = new ConfEagerSources.YamlFile(\"config.yaml\", 10);\n// now use the source to instantiate a configuration object\n// and bind it to the source, so that when the source data\n// updated, the configuration instance immidietaly gets updated too.\nconst conf = source.create(Configuration);\n\n// that's it, let's use it!\nconf.host;                                // =\u003e \"0.0.0.0\"\nconf.port;                                // =\u003e 8080\nconf.useHttps;                            // =\u003e false\nconf.logLevel;                            // =\u003e LogLevel.INFO\nconf.nestedConfiguration.nestedProperty;  // =\u003e 1234\nconf.arrayConfiguration;                  // =\u003e [1234, 2345]\nconf.optionalProperty;                    // =\u003e \"value\"\n```\n\nFull documentation can be found on the project [WIKI on GitHub](https://github.com/avivcarmis/conf-eager-js/wiki \"WIKI on GitHub\").\n\n## Why?\nConfEagerJS is designed with two main charachteristics: being eager and being strongly-typed. This is a very powerful combination that provides a few main advantages.\n\nAs opposed to popular configuration libraries, ConfEagerJS provides you with an \ninterface for declaring your exact expectations from the configuration data. In addition, properties are eagerly loaded and validated. This combination renders a system that validates your entire configuration data source at boot time. The existance and value validity of each property in the source is validated immidiately. This also means no need to check for `null` and no null pointer errors either. This means no more typos when reading from the configuration, and most importantly, this means that to discover these kind of bugs you do not have to discover the exact control flow that triggers it, but rather let ConfEager find it for you when it loads.\n\nAdditionally, ConfEagerJS is aimed to provide simple means to easily implement any data source you like, seamlessly get data updates from it without the need to restart your application, and consume any property type you would like from it.\n\nConfEagerJS follows a [big sister project for Java](https://github.com/avivcarmis/conf-eager \"big sister project for Java\").\n\n## Useful Links\n- [The project GitHub page](https://github.com/avivcarmis/conf-eager-js \"The project GitHub page\")\n- [The project Issue Tracker on GitHub](https://github.com/avivcarmis/conf-eager-js/issues \"The project Issue Tracker on GitHub\")\n- [The project build Status at Travis CI](https://travis-ci.org/avivcarmis/conf-eager-js \"The project build Status at Travis CI\")\n\n## License\nConfEagerJS is registered under \u003ca href=/LICENSE.txt target=\"_blank\"\u003eMIT\u003c/a\u003e license.\n\n## Contribution\nReally, any kind of contribution will be warmly accepted. (:\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Favivcarmis%2Fconf-eager-js","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Favivcarmis%2Fconf-eager-js","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Favivcarmis%2Fconf-eager-js/lists"}