{"id":18583534,"url":"https://github.com/maxdome/mxd-config","last_synced_at":"2025-05-16T05:09:49.965Z","repository":{"id":57305951,"uuid":"61203058","full_name":"maxdome/mxd-config","owner":"maxdome","description":"Loads the 'config/properties.json' if available and allow to overwrite the port by enviroment variable","archived":false,"fork":false,"pushed_at":"2017-03-23T14:40:56.000Z","size":12,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-05-09T17:21:33.869Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"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/maxdome.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}},"created_at":"2016-06-15T11:31:51.000Z","updated_at":"2016-12-30T11:05:43.000Z","dependencies_parsed_at":"2022-09-20T21:50:18.362Z","dependency_job_id":null,"html_url":"https://github.com/maxdome/mxd-config","commit_stats":null,"previous_names":["maxdome/config"],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/maxdome%2Fmxd-config","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/maxdome%2Fmxd-config/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/maxdome%2Fmxd-config/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/maxdome%2Fmxd-config/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/maxdome","download_url":"https://codeload.github.com/maxdome/mxd-config/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254471049,"owners_count":22076587,"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-11-07T00:23:26.709Z","updated_at":"2025-05-16T05:09:49.950Z","avatar_url":"https://github.com/maxdome.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Description\n\nFiles which will be required (all files can be defined as JSON and .js CommonJS module):\n\n* If environment is undefined or 'development':\n    1. `/config/all`\n    2. `/config/development`\n    3. `/config/properties`\n* Else:\n    1. `/config/all`\n    2. `/config/properties`\n  \nThe later required files overwrites the others. If an attribute is defined as array, the complete attribute will be overwritten.\n\n# Example\n\n```\nconst config = require('mxd-config')();\n// if the environment is later needed use 'config.environment' \n```\n\n## Configuration\n\nThe environment will be defined by `NODE_ENV` but can be overwritten:\n```\nconst config = require('mxd-config')('development');\n```\n\nAdditional filenames (located in the config directory) can be defined, which also will be loaded:\n```\nconst config = require('mxd-config')(['lambda']);\n```\n\nIf both (environment and additional filenames) are needed, use a config object: \n```\nconst config = require('mxd-config')({ \n  environment: 'development',\n  filenames: ['lambda'], \n});\n```\n\n## dotenv\n\nThis module silently loads `/.env.\u003cNODE_ENV\u003e` configs in the project root, e.g. `/.env.production` if one is found.\nAs a result, we can simply start the app using `NODE_ENV=test node app.js` which loads `/.env.test` into the config. \n\nFor development purposes, the module also silently loads a \"generic\" `/.env`, config regardless of the environment.\nThe variables contained here override those in `/.env.\u003cNODE_ENV\u003e`.\n\n## Environment Getters\n\nUsing environment getters, we can get environment variables and cast a type and a default value on them:\n\n```\nconst { getBool, getInt, getList, getStr } = require('mxd-config').util;\n\nmodule.exports = {\n  myBool: getBool('MY_BOOL', true),\n  myInteger: getInt('MY_INT', 123),\n  myString: getStr('MY_STRING', 'foo'),\n  myList: getList('MY_LIST', ['foo', 'bar', 'baz'])\n};\n```\n\nWith no environment variables set, this outputs\n\n```\n{\n  myBool: true,\n  myInteger: 123,\n  myString: 'foo',\n  myList: ['foo', 'bar', 'baz']\n}\n```\n\nHere's an example `.env.development` file:\n\n```\nMY_BOOL=off\nMY_INT=456\nMY_STRING=bar\nMY_LIST=baz|bar|foo\n```\n\nThis outputs\n\n```\n{\n  myBool: false,\n  myInteger: 456,\n  myString: 'bar',\n  myList: ['baz', 'bar', 'foo']\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmaxdome%2Fmxd-config","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmaxdome%2Fmxd-config","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmaxdome%2Fmxd-config/lists"}