{"id":15776080,"url":"https://github.com/hapinessjs/config","last_synced_at":"2025-10-20T00:04:18.837Z","repository":{"id":57115146,"uuid":"90629045","full_name":"hapinessjs/config","owner":"hapinessjs","description":"Configuration library based on node-config library","archived":false,"fork":false,"pushed_at":"2018-09-28T08:46:54.000Z","size":120,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":5,"default_branch":"master","last_synced_at":"2025-03-27T19:52:07.592Z","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/hapinessjs.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-05-08T13:06:06.000Z","updated_at":"2018-09-28T08:46:31.000Z","dependencies_parsed_at":"2022-08-22T10:40:36.767Z","dependency_job_id":null,"html_url":"https://github.com/hapinessjs/config","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hapinessjs%2Fconfig","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hapinessjs%2Fconfig/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hapinessjs%2Fconfig/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hapinessjs%2Fconfig/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/hapinessjs","download_url":"https://codeload.github.com/hapinessjs/config/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246484869,"owners_count":20785171,"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-10-04T17:04:49.358Z","updated_at":"2025-10-20T00:04:18.741Z","avatar_url":"https://github.com/hapinessjs.png","language":"TypeScript","readme":"\u003cimg src=\"http://bit.ly/2mxmKKI\" width=\"500\" alt=\"Hapiness\" /\u003e\n\n\u003cdiv style=\"margin-bottom:20px;\"\u003e\n\u003cdiv style=\"line-height:60px\"\u003e\n    \u003ca href=\"https://travis-ci.org/hapinessjs/config.svg?branch=master\"\u003e\n        \u003cimg src=\"https://travis-ci.org/hapinessjs/config.svg?branch=master\" alt=\"build\" /\u003e\n    \u003c/a\u003e\n    \u003ca href=\"https://coveralls.io/github/hapinessjs/config?branch=master\"\u003e\n        \u003cimg src=\"https://coveralls.io/repos/github/hapinessjs/config/badge.svg?branch=master\" alt=\"coveralls\" /\u003e\n    \u003c/a\u003e\n    \u003ca href=\"https://david-dm.org/hapinessjs/config\"\u003e\n        \u003cimg src=\"https://david-dm.org/hapinessjs/config.svg\" alt=\"dependencies\" /\u003e\n    \u003c/a\u003e\n    \u003ca href=\"https://david-dm.org/hapinessjs/config?type=dev\"\u003e\n        \u003cimg src=\"https://david-dm.org/hapinessjs/config/dev-status.svg\" alt=\"devDependencies\" /\u003e\n    \u003c/a\u003e\n\u003c/div\u003e\n\u003cdiv\u003e\n    \u003ca href=\"https://www.typescriptlang.org/docs/tutorial.html\"\u003e\n        \u003cimg src=\"https://cdn-images-1.medium.com/max/800/1*8lKzkDJVWuVbqumysxMRYw.png\"\n             align=\"right\" alt=\"Typescript logo\" width=\"50\" height=\"50\" style=\"border:none;\" /\u003e\n    \u003c/a\u003e\n    \u003ca href=\"http://reactivex.io/rxjs\"\u003e\n        \u003cimg src=\"http://reactivex.io/assets/Rx_Logo_S.png\"\n             align=\"right\" alt=\"ReactiveX logo\" width=\"50\" height=\"50\" style=\"border:none;\" /\u003e\n    \u003c/a\u003e\n    \u003ca href=\"http://hapijs.com\"\u003e\n        \u003cimg src=\"http://bit.ly/2lYPYPw\"\n             align=\"right\" alt=\"Hapijs logo\" width=\"75\" style=\"border:none;\" /\u003e\n    \u003c/a\u003e\n\u003c/div\u003e\n\u003c/div\u003e\n\n# Hapiness Config\n\nConfiguration module based on [node-config](https://github.com/lorenwest/node-config) \u0026 [js-yaml](https://github.com/nodeca/js-yaml) libraries.\n\n## Table of contents\n\n* [Using config module](#using-config-module)\n    * [Yarn or NPM it in your package.json](#yarn-or-npm-it-in-your-packagejson)\n    * [Standalone](#standalone)\n    * [Hapiness](#hapiness)\n* [Change History](#change-history)\n* [Maintainers](#maintainers)\n* [License](#license)\n\n## Using config module\n\n### `yarn` or `npm` it in your `package.json`\n\n```bash\n$ npm install --save @h@hapiness/config\n\nor\n\n$ yarn add @hapiness/config\n```\n\n```javascript\n\"dependencies\": {\n    \"@hapiness/config\": \"^1.2.1\",\n    //...\n}\n//...\n```\n\n### Standalone\n\n`./config/default.yml`:\n\n```yaml\nmy:\n    config: test\n```\n\n\n`Node.js Script`:\n\n```javascript\nimport { Config } from '@hapiness/config';\n\nif (Config.has('my.config')) {\n    console.log(Config.get('my.config')); // output: 'test'\n}\n```\n\n### Hapiness\n\n`./config/default.yml`:\n\n```yaml\nexternal_service:\n    baseUrl: 'test'\n\nmymodule_database:\n    provider: postgresql\n    hostname: localhost\n    user: pguser\n    password: keyboard cat\n```\n\n`Hapiness module`:\n\n```javascript\n// external-module.ts\n  import {\n    HapinessModule,\n    CoreModuleWithProviders,\n    InjectionToken,\n    Inject,\n    Optional,\n  } from '@hapiness/core';\n\n  import { ConfigHelper, ConfigInterface } from '@hapiness/config';\n\n    @HapinessModule({\n        ...\n    })\n\n    export class ExternalModule {\n        static setConfig(config: ConfigInterface): CoreModuleWithProviders {\n            return {\n                module: ExternalModule,\n                providers: [ConfigHelpers.getProvider('mymodule_database', config)]\n            };\n        }\n    }\n\n    export class Service {\n      constructor(@Optional() @Inject(ConfigHelper.getInjectionToken('mymodule_database')) config) { // @Optional to not throw errors if config is not passed\n        ...\n      }\n    }\n```\n\n```javascript\n\n    // main-module.ts\n    import {\n      HapinessModule,\n    } from '@hapiness/core';\n    import { ExternalModule } from 'external-module';\n    import { Config } from '@hapiness/config';\n\n    @HapinessModule({\n        ...\n        imports: [ ExternalModule.setConfig(Config.get('mymodule_database')) ]\n    })\n    ...\n```\n\n`Hapiness service`:\n\n```javascript\n\n    // main-module.ts\n    import {\n      HapinessModule,\n    } from '@hapiness/core';\n    import { ConfigHelper, Config } from '@hapiness/config';\n    import { MyCustomService } from './services';\n\n    @HapinessModule({\n        ...\n        providers: [\n            ConfigHelper.getProvider('external_service'),\n            MyCustomService,\n            ...\n        ]\n    })\n    ...\n```\n\n```javascript\n    import { Injectable } from '@hapiness/core';\n    import { ConfigInterface } from '@hapiness/config';\n\n    // my-custom-service.ts\n    @Injectable()\n    class MyCustomService {\n\n        private _baseUrl: string;\n\n        constrcutor(\n            @Inject(ConfigHelper.getInjectionToken('external_service'))\n            private _config: ConfigInterface\n        ) {}\n\n        connect() {\n            this._baseUrl = this._config.get\u003cstring\u003e('baseUrl');\n        }\n\n    }\n    ...\n```\n\n[Back to top](#table-of-contents)\n\n## Change History\n* v1.2.1 (2018-09-26)\n    * Fix a bug when default value of `get()` was a falsy value and wrongly interpreted as undefined\n* v1.2.0 (2018-05-09)\n    * Delete obsolete `peerDependencies`\n    * Latest packages' versions\n    * Documentation\n* v1.1.1 (2017-12-28)\n    * Fix load `config`\n* v1.1.0 (2017-11-20)\n    * Latest packages' versions.\n    * Documentation.\n    * Change packaging process.\n* v1.0.0 (2017-10-27)\n    * Create `Config` module.\n    * Tests module.\n    * Documentation.\n    * First stable version.\n\n[Back to top](#table-of-contents)\n\n## Maintainers\n\n\u003ctable\u003e\n    \u003ctr\u003e\n        \u003ctd colspan=\"4\" align=\"center\"\u003e\u003ca href=\"https://www.tadaweb.com\"\u003e\u003cimg src=\"http://bit.ly/2xHQkTi\" width=\"117\" alt=\"tadaweb\" /\u003e\u003c/a\u003e\u003c/td\u003e\n    \u003c/tr\u003e\n    \u003ctr\u003e\n        \u003ctd align=\"center\"\u003e\u003ca href=\"https://github.com/Juneil\"\u003e\u003cimg src=\"https://avatars3.githubusercontent.com/u/6546204?v=3\u0026s=117\" width=\"117\"/\u003e\u003c/a\u003e\u003c/td\u003e\n        \u003ctd align=\"center\"\u003e\u003ca href=\"https://github.com/antoinegomez\"\u003e\u003cimg src=\"https://avatars3.githubusercontent.com/u/997028?v=3\u0026s=117\" width=\"117\"/\u003e\u003c/a\u003e\u003c/td\u003e\n        \u003ctd align=\"center\"\u003e\u003ca href=\"https://github.com/reptilbud\"\u003e\u003cimg src=\"https://avatars3.githubusercontent.com/u/6841511?v=3\u0026s=117\" width=\"117\"/\u003e\u003c/a\u003e\u003c/td\u003e\n        \u003ctd align=\"center\"\u003e\u003ca href=\"https://github.com/njl07\"\u003e\u003cimg src=\"https://avatars3.githubusercontent.com/u/1673977?v=3\u0026s=117\" width=\"117\"/\u003e\u003c/a\u003e\u003c/td\u003e\n    \u003c/tr\u003e\n    \u003ctr\u003e\n        \u003ctd align=\"center\"\u003e\u003ca href=\"https://github.com/Juneil\"\u003eJulien Fauville\u003c/a\u003e\u003c/td\u003e\n        \u003ctd align=\"center\"\u003e\u003ca href=\"https://github.com/antoinegomez\"\u003eAntoine Gomez\u003c/a\u003e\u003c/td\u003e\n        \u003ctd align=\"center\"\u003e\u003ca href=\"https://github.com/reptilbud\"\u003eSébastien Ritz\u003c/a\u003e\u003c/td\u003e\n        \u003ctd align=\"center\"\u003e\u003ca href=\"https://github.com/njl07\"\u003eNicolas Jessel\u003c/a\u003e\u003c/td\u003e\n    \u003c/tr\u003e\n\u003c/table\u003e\n\n[Back to top](#table-of-contents)\n\n## License\n\nCopyright (c) 2018 **Hapiness** Licensed under the [MIT license](https://github.com/hapinessjs/config/blob/master/LICENSE.md).\n\n[Back to top](#table-of-contents)\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhapinessjs%2Fconfig","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhapinessjs%2Fconfig","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhapinessjs%2Fconfig/lists"}