{"id":19389053,"url":"https://github.com/yyyar/config-getter","last_synced_at":"2025-10-26T11:32:11.087Z","repository":{"id":27068909,"uuid":"30535202","full_name":"yyyar/config-getter","owner":"yyyar","description":"Simple JSON configuration reader with flexible configuration override options","archived":false,"fork":false,"pushed_at":"2024-07-05T16:42:51.000Z","size":15,"stargazers_count":2,"open_issues_count":0,"forks_count":3,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-02T22:33:06.477Z","etag":null,"topics":["config","configuration","javascript","json","node","nodejs"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","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/yyyar.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2015-02-09T12:40:57.000Z","updated_at":"2024-07-05T16:42:54.000Z","dependencies_parsed_at":"2024-07-05T18:15:07.159Z","dependency_job_id":"2705b070-2006-4574-96e5-e050bb57a7ad","html_url":"https://github.com/yyyar/config-getter","commit_stats":{"total_commits":9,"total_committers":1,"mean_commits":9.0,"dds":0.0,"last_synced_commit":"2744d13f21a5558979f8350510364787944a5fbb"},"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yyyar%2Fconfig-getter","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yyyar%2Fconfig-getter/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yyyar%2Fconfig-getter/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yyyar%2Fconfig-getter/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/yyyar","download_url":"https://codeload.github.com/yyyar/config-getter/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250532186,"owners_count":21446133,"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":["config","configuration","javascript","json","node","nodejs"],"created_at":"2024-11-10T10:14:37.737Z","updated_at":"2025-10-26T11:32:11.024Z","avatar_url":"https://github.com/yyyar.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"## config-getter\n\n[![Build Status](https://travis-ci.org/yyyar/config-getter.svg?branch=master)](https://travis-ci.org/yyyar/config-getter) [![NPM version](https://badge.fury.io/js/config-getter.svg)](http://badge.fury.io/js/config-getter)\n\nSimple json configuration reader with file and env variables overrides.\nCan fetch / override variables using:\n- Local file\n- Env variables\n- Consul key-value\n\nFor 0.0.x versions documentation see [older README.md](https://github.com/yyyar/config-getter/blob/v0.0.7/README.md)\n\n### Installation\n```bash\n$ npm install config-getter\n```\n\n### Usage\n\n`default.js`\n```javascript\nmodule.exports = {\n    \"db\": {\n        \"host\": \"localhost\",\n        \"port\": \"12345\"\n    }\n}\n```\n\n`overrides.json`\n```javascript\n{\n    \"db\": {\n        \"host\": \"google.com\"\n    }\n}\n```\n\n`app.js`\n\nUsing with import:\n```javascript\n\n// @ts-ignore\nimport configGetter from 'config-getter';\n\nimport defaultConfig from './default.js';\n\nexport default configGetter.extendConfig(defaultConfig, {\n    // ... parameters ... //\n};\n```\n\nOld way:\n\n```javascript\nconst getConfig = require('config-getter').getConfig;\n\n//\n// Obtain final configuration object.\n//\n// Important Notice: even that underlying fetchers use async IO,\n// interface to getConfig is sync for usability purposes. \n// As a result, Application that use config-getter should do getConfig once at startup time.\n//\nlet config = getConfig(__dirname + '/default.js', {\n\n    /* ----- optional parameters ----- */\n\n    // function to get log messages\n    log: console.log,\n\n    // if true, replaces arrays values\n    // If false, merge arrays\n    replaceArrays: false,\n\n    // if true, replaces objects values\n    // If false, merge objects\n    replaceObjects: false,\n\n    // If true, ignore fetcher exceptions and continue work\n    // If false, throw/propagate all exceptions\n    ignoreFailedFetchers: false,\n\n    // Optional fetchers\n    // Values from these fetchers will be merged into default config\n    // in order of their appear in the following array:\n    fetchers: [\n\n        /* ----- one or more of the following ----- */\n\n        {\n            type: 'consul',\n            opts: {\n                baseUrl: 'http://localhost:8500/v1',  // base url for Consul REST API\n                key: 'config'                         // key to look for JSON value\n            }\n        },\n\n        {\n            type: 'file',\n            opts: {\n                path: process.env.PATH_TO_CONFIG       // path to json file\n            }\n        },\n\n        {\n            type: 'env',\n            opts: {\n                prefix: 'CONFIG_',                    // prefix of env variable used to override values\n                ignore: '^PATH_TO_CONFIG$'            // regexp to ignore env variable if there is a match\n            }\n        }\n    ]\n\n});\n\nconsole.log(config);\n\n```\n\nSimple config loading\n```bash\n$ node app.js\n```\n\nOverride config with overrides.json values\n```bash\n$ PATH_TO_CONFIG=./overrides.json node app.js\n```\n\nOverride config with overrides.json values and single key value\n```bash\n$ PATH_TO_CONFIG=./overrides.json CONFIG_db_port=7777 node app.js\n```\n\n### Placeholders\nIt's possible to make a reference to previous defined value in some config string value:\n```json\n{\n   \"who\": \"world\",\n   \"phrase\": \"hello, $(who)!\"\n}\n```\nSo phrase will become \"hello, world!\". It is possbile to make reference in inner objects too:\n```json\n\"$(some.obj.value)\"\n```\n\nPlaceholders also may be relative. Currently the same level, and parent level are supported.\n```javascript\n{\n    \"a\": {\n        \"a1\": {\n            \"name\": \"Vasya\",\n            \"phrase\": \"My name is $(.name)\" // link to the same level var starts with single dot '.'\n       },\n       \"a2\": {\n           \"name\": \"$(..a1.name)\" // link to upper level var starts with two dots '..'\n       }\n    }\n}\n```\n\n#### Tests\n```bash\n$ npm install\n$ npm test\n```\n\n#### Author\n* [Yaroslav Pogrebnyak](https://github.com/yyyar/)\n\n#### License\nMIT\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyyyar%2Fconfig-getter","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fyyyar%2Fconfig-getter","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyyyar%2Fconfig-getter/lists"}