{"id":21117635,"url":"https://github.com/jimzhan/convict-register","last_synced_at":"2026-05-12T04:33:24.192Z","repository":{"id":57206958,"uuid":"140043167","full_name":"jimzhan/convict-register","owner":"jimzhan","description":"Registration helper for node-convict, a featureful configuration management library for Node.js","archived":false,"fork":false,"pushed_at":"2018-09-20T03:56:56.000Z","size":293,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-08T00:02:02.361Z","etag":null,"topics":["application","automatic","config","configuration","configuration-management","convict","env","environment-variables","javasacript","json","json-files","node","nodejs","require-context","schema","settings","validation"],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jimzhan.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-07-07T01:26:46.000Z","updated_at":"2018-09-20T03:56:58.000Z","dependencies_parsed_at":"2022-09-11T05:20:24.834Z","dependency_job_id":null,"html_url":"https://github.com/jimzhan/convict-register","commit_stats":null,"previous_names":[],"tags_count":9,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jimzhan%2Fconvict-register","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jimzhan%2Fconvict-register/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jimzhan%2Fconvict-register/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jimzhan%2Fconvict-register/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jimzhan","download_url":"https://codeload.github.com/jimzhan/convict-register/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243565414,"owners_count":20311703,"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":["application","automatic","config","configuration","configuration-management","convict","env","environment-variables","javasacript","json","json-files","node","nodejs","require-context","schema","settings","validation"],"created_at":"2024-11-20T02:46:44.155Z","updated_at":"2026-05-12T04:33:24.133Z","avatar_url":"https://github.com/jimzhan.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# convict-register\n\nRegistration helper for [node-convict](https://github.com/mozilla/node-convict), a featureful configuration management library for Node.js.\n\n[![build](https://travis-ci.org/jimzhan/convict-register.svg?branch=master)](https://travis-ci.org/jimzhan/convict-register)\n[![npm version](https://badge.fury.io/js/convict-register.svg)](https://www.npmjs.com/package/convict-register)\n[![JavaScript Style Guide](https://camo.githubusercontent.com/387caee7992b38dcac6cb23f87abf0ba139d7101/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f636f64652532307374796c652d616972626e622d626c75652e737667)](https://github.com/airbnb/javascript)\n[![Commitizen friendly](https://img.shields.io/badge/commitizen-friendly-brightgreen.svg)](http://commitizen.github.io/cz-cli/)\n\nWith [dotenv](https://github.com/motdotla/dotenv) together, `convict-register` expands `convict` further by automatically registering all of the modules under the given folder to easily create a modular settings structures by splitting domain settings via files for large application.\n\n\n## Install\n\n```shell\nnpm install convict-register\n```\n\n## Usage\n\nAn sample structure of settings folder.\n\n```\n- settings/\n  db.js\n  redis.js\n  index.js\n```\n\nSample in `settings/db.js`.\n\n```javascript\nmodule.exports = {\n  username: {\n    format: String,\n    default: 'dbuser',\n    env: 'DB_USER',\n  },\n}\n```\n\nSample in `settings/index.js`.\n\n```javascript\nconst Settings = require('convict-register')\n\n/*\n  Arguments\n    - abspath: absolute path to the folder with settings modules.\n    - recursive: whether to recursively find all settings modules.\n    - settings: top level settings values.\n*/\nmodule.exports = new Settings({\n  env: {\n    doc: 'Deployment environment',\n    format: String,\n    default: 'development',\n    env: 'NODE_ENV',\n  },\n  host: {\n    format: String,\n    default: '0.0.0.0',\n    env: 'HOST',\n  },\n  port: {\n    format: 'port',\n    default: 9394,\n    env: 'PORT',\n  },\n  keys: {\n    doc: 'Application secret keys',\n    format: Array,\n    default: [],\n    env: 'SECRET',\n  },\n})\n```\n\nUsing settings elsewhere (e.g. `main.js`):\n\n```javascript\ndotenv.config()\n\nconst settings = require('./settings')\n\nconsole.log(settings.get('port'))           // 9394\nconsole.log(settings.get('db.username'))    // dbuser\n\n```\n\nThe `settings.convict` object is essentially a `convict` object, meaning that you still have full capacity of [convict](https://github.com/mozilla/node-convict).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjimzhan%2Fconvict-register","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjimzhan%2Fconvict-register","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjimzhan%2Fconvict-register/lists"}