{"id":18273296,"url":"https://github.com/spacetab-io/configuration-js","last_synced_at":"2026-05-01T06:33:05.643Z","repository":{"id":39413734,"uuid":"265155039","full_name":"spacetab-io/configuration-js","owner":"spacetab-io","description":null,"archived":false,"fork":false,"pushed_at":"2023-01-06T06:20:31.000Z","size":3999,"stargazers_count":1,"open_issues_count":8,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-05-29T07:05:47.614Z","etag":null,"topics":["configuration","js","microservices","ts","winston"],"latest_commit_sha":null,"homepage":"https://spacetab.io","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/spacetab-io.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":"code-of-conduct.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-05-19T05:35:45.000Z","updated_at":"2021-07-15T19:25:35.000Z","dependencies_parsed_at":"2023-02-05T12:46:16.463Z","dependency_job_id":null,"html_url":"https://github.com/spacetab-io/configuration-js","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"purl":"pkg:github/spacetab-io/configuration-js","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/spacetab-io%2Fconfiguration-js","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/spacetab-io%2Fconfiguration-js/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/spacetab-io%2Fconfiguration-js/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/spacetab-io%2Fconfiguration-js/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/spacetab-io","download_url":"https://codeload.github.com/spacetab-io/configuration-js/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/spacetab-io%2Fconfiguration-js/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32487440,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-30T13:12:12.517Z","status":"online","status_checked_at":"2026-05-01T02:00:05.856Z","response_time":64,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"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":["configuration","js","microservices","ts","winston"],"created_at":"2024-11-05T12:05:55.738Z","updated_at":"2026-05-01T06:33:05.629Z","avatar_url":"https://github.com/spacetab-io.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"Javascript microservice configuration library\n---------------------------------------------\n\n[![Build Status](https://travis-ci.org/microparts/configuration-js.svg?branch=master)](https://travis-ci.org/microparts/configuration-js)\n\nProduction-ready configuration for microservices. Written in TypeScript.\nLibrary works with nodejs apps and with [browsers*](#how-to-usage-library-with-spa-apps).\n\nLibrary created for follow up corporate standards of application configuration.\n\n## Installation\n\n```bash\nnpm install --save @spacetab-io/configuration-js\n// or\nyarn add @spacetab-io/configuration-js\n```\n\n## Usage\n\nBy default, path to configuration directory and application stage\nloading from `/app/configuration` with `local` stage.\n\n1) Simple\n```ts\nimport { Configuration } from '@spacetab-io/configuration-js';\n\nconst conf = new Configuration();\nconf.load();\n\nconsole.log(conf.all()); // get all config\nconsole.log(conf.get('foo.bar')); // get nested key use dot notation\n```\n\n2) If u would like override default values, you can pass 2 arguments to\nclass constructor or set up use setters.\n\n```ts\nimport { Configuration } from '@spacetab-io/configuration-js';\n\nconst conf = new Configuration('./configuration', 'test');\n// or\n// conf.path = './configs';\n// conf.stage = 'local';\nconf.load();\n\nconf.get('foo'); // full example on the top\n```\n\n3) If the operating system has an env variables `CONFIG_PATH` and `STAGE`,\nthen values for the package will be taken from there.\n\n```bash\nexport CONFIG_PATH=/configuration\nexport STAGE=prod\n```\n\n```ts\nimport { Configuration } from '@spacetab-io/configuration-js';\n\nconst conf = new Configuration('./configuration', 'test');\nconf.load(); // loaded files from /configuration for prod stage.\n\nconf.get('foo'); // full example on the top\n```\n\n4) If u want to see logs and see how load process working,\npass you logger to property:\n\nPass it like this:\n```ts\nimport { Configuration, StdoutConsoleLogger } from '@spacetab-io/configuration-js';\n\nconst conf = new Configuration();\nconf.logger = new StdoutConsoleLogger();\nconf.load();\n\nconf.get('foo'); // full example on the top\n```\n\nOr if you would like use external logger, like [Winston](https://github.com/winstonjs/winston), you can\nintegrate it with [LoggerInterface](./src/logger-interface.ts). Just a write the adapter like as [WinstonConsoleLogger](./src/winston-console-logger.ts).\n\nFor now, by default library support one Winston transport called `Console`.\nOkay, let's go use adapter for him...\n\nFirst, install logger:\n```bash\nnpm install --save winston\n// or yarn add winston\n```\n\nSecond, pass you logger to property like this:\n```ts\nimport { Configuration, WinstonConsoleLogger, StdoutConsoleLogger } from '@spacetab-io/configuration-js';\n\nconst conf = new Configuration();\nconf.logger = new WinstonConsoleLogger(winston.createLogger({\n  transports: [new winston.transports.Console()]\n}));\n\nconf.load();\n\nconf.get('foo'); // get value of `foo`\n```\n\n## How to usage library with SPA apps?\n\n**Note:** \u003cbr\u003e\nhttps://github.com/spacetab-io/static-server-php is required for usage on the server/cloud.\n\nFor most cases, this [Dockerfile](./example/vue-app/Dockerfile) can help your application build's in the cloud.\n\nIt simple. Step by step:\n\n1. Create an vue app for example\n```bash\nvue create vue-app\n```\n2. Install this package\n```bash\nnpm install --save @spacetab-io/configuration-js\n```\n3. Put config files [like this](./example/vue-app/configuration)\n4. Change `vue.config.js` to build final config to global variables:\n```js\nconst { Configuration, StdoutConsoleLogger } = require('@spacetab-io/configuration-js');\n\nmodule.exports = {\n  lintOnSave: false,\n  chainWebpack: config =\u003e {\n    config.plugin('html').tap(options =\u003e {\n      const conf = new Configuration('./configuration');\n      conf.logger = new StdoutConsoleLogger(); // new StdoutConsoleLogger(true); // for debug\n      conf.load();\n\n      options[0].__config = conf.asEscapedJson();\n      options[0].__stage = conf.stage;\n\n      return options;\n    });\n  }\n};\n```\n\n5. Add following code to `index.html` to **top** of `\u003chead\u003e` html tag (**before all scripts**):\n\n```html\n\u003chead\u003e\n  \u003c% if (htmlWebpackPlugin.options.__stage === 'local') { %\u003e\n    \u003cscript\u003e\n      window.__config = JSON.parse(\"\u003c%= htmlWebpackPlugin.options.__config %\u003e\");\n      window.__stage = '\u003c%= htmlWebpackPlugin.options.__stage %\u003e';\n      window.__vcs = '';\n    \u003c/script\u003e\n  \u003c% } %\u003e\n\u003c!-- ... meta tags and other code --\u003e\n```\n\n6. Add globals to `.eslintrc`:\n\n```json\n\"globals\": {\n  \"__config\": \"readonly\",\n  \"__stage\": \"readonly\",\n  \"__vcs\": \"readonly\"\n },\n```\n\n7. Run application.\n```bash\nnpm run serve\n```\n\nFull example available at [here](./example/vue-app).\n\n## License\n\nThe MIT License\n\nCopyright © 2021 spacetab.io, Inc. https://spacetab.io\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in\nall copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\nTHE SOFTWARE.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fspacetab-io%2Fconfiguration-js","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fspacetab-io%2Fconfiguration-js","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fspacetab-io%2Fconfiguration-js/lists"}