{"id":18656756,"url":"https://github.com/optimalbits/sconf","last_synced_at":"2025-07-25T08:05:08.721Z","repository":{"id":14935972,"uuid":"17660460","full_name":"OptimalBits/sconf","owner":"OptimalBits","description":"Simple Configuration for NodeJS Applications","archived":false,"fork":false,"pushed_at":"2024-01-18T13:10:07.000Z","size":8,"stargazers_count":7,"open_issues_count":0,"forks_count":1,"subscribers_count":5,"default_branch":"master","last_synced_at":"2025-06-15T18:02:48.645Z","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":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/OptimalBits.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","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,"zenodo":null}},"created_at":"2014-03-12T08:39:26.000Z","updated_at":"2024-01-18T13:09:17.000Z","dependencies_parsed_at":"2025-04-11T20:52:27.811Z","dependency_job_id":"be751f43-bcbd-4078-bcc2-920e40db05b5","html_url":"https://github.com/OptimalBits/sconf","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/OptimalBits/sconf","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/OptimalBits%2Fsconf","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/OptimalBits%2Fsconf/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/OptimalBits%2Fsconf/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/OptimalBits%2Fsconf/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/OptimalBits","download_url":"https://codeload.github.com/OptimalBits/sconf/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/OptimalBits%2Fsconf/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":266977782,"owners_count":24015481,"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","status":"online","status_checked_at":"2025-07-25T02:00:09.625Z","response_time":70,"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":[],"created_at":"2024-11-07T07:25:07.249Z","updated_at":"2025-07-25T08:05:08.712Z","avatar_url":"https://github.com/OptimalBits.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"sconf\n=====\n\nSimple Configuration for NodeJS Applications.\n\nWhy?\n====\n\nBecause you need a well defined metodology to configure your applications both for\ndevelopment and deployment instead of reinventing the wheel for every application\nor hacking configuration values.\n\n*sconf* follows the twelve-factor app [guidelines](http://www.12factor.net/config).\n\nYou should define the application configuration by setting environment variables, \nbut you can have convenient defaults for development, testing or some special\ndevelopment configurations.\n\nAll configuration items can be optionally prefixed, to avoid conflict with\nother applications that may be running in the same environment.\n\nInstallation\n============\n\n```\n  npm install sconf\n```\n\nExamples:\n=========\n\n```\n  var $ = require('sconf');\n\n  var config = {\n    appPort: $('APP_PORT', 8080),\n    redisUri: $('REDIS_PORT', 'tcp://example.com:6379'),\n  }\n  \n  //  config.appPort contains 8080 or the value of env.APP_PORT\n  \n  /*\n   config.redisUri:\n      redisUri:\n         { protocol: 'tcp:',\n           slashes: true,\n           auth: null,\n           host: 'example.com:6379',\n           port: '6379',\n           hostname: 'example.com',\n           hash: null,\n           search: null,\n           query: null,\n           pathname: null,\n           path: null,\n           href: 'tcp://example.com:6379' }\n   */\n```\n\nUsing prefixes:\n\n```\n  // prefixed config\n  var config = $.prefix('MY_APP')({\n    appPort: $('PORT', 8080),\n    redisUri: $('REDIS_URI', 'tcp://example.com:6379'),\n  });\n  \n  // tries to read from environment variables MY_APP_PORT, MY_APP_REDIS_PORT\n\n  // we can extend with an unprefixed config\n  $.extend(config, $({mode: $('NODE_ENV')}))  \n```\n\nIt also supports hierarchies:\n\n```\n var config = $.prefix('MY_APP')({\n   appPort: $('PORT', 8080),\n   db: $.prefix('DB')({\n     redisUri: $('REDIS_URI', 'tcp://example.com:6379');\n   })\n })\n \n// tries to read from environment variables MY_APP_PORT, MY_APP_DB_REDIS_PORT\n```\n\nBest Practices\n==============\n\nUse a single config.js file for your application. Export the configuration\nand include that file in all the required server files.\n\n```\n  // config.js\n\n  var $ = require('sconf');\n\n  module.exports = {\n    appPort: $('APP_PORT', 8080),\n    redisUri: $('REDIS_PORT', 'tcp://example.com:6379'),\n  }\n```\n\n\nAPI\n===\n\n```\n\n  /**\n    Creates a configuration entry. \n    \n    @params envName Environment variable name\n    @params defaultDevelopment optional default value in development mode\n    @params defaultTest optional efault value in test mode\n    @params defaultProduction optional default value in production mode\n    \n    @returns a value for this entry. Note, if the value is a valid URL, then\n    it gets parsed and a URL object is returned instead.\n  */\n  $(envName, defaultDevelopment, defaultTest, defaultProduction)\n  \n  \n  /**\n    Adds a prefix to the environment variable names.\n    \n    @returns A sconf object with the given prefix appended to it.\n  */\n  $.prefix(prefix)\n  \n  \n  /**\n    Creates a configuration object based on the current prefix hierarchy.\n    \n    @param object\n    @returns object with all the values populated.\n  */\n  $(object)\n  \n\n```\n\n\nLicense\n=======\n\n(The MIT License)\n\nCopyright (c) 2013 Manuel Astudillo manuel@optimalbits.com\n\nPermission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the 'Software'), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Foptimalbits%2Fsconf","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Foptimalbits%2Fsconf","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Foptimalbits%2Fsconf/lists"}