{"id":15578301,"url":"https://github.com/phaalonso/config-typing","last_synced_at":"2025-04-24T01:10:21.753Z","repository":{"id":57146528,"uuid":"394136003","full_name":"phaalonso/config-typing","owner":"phaalonso","description":"An Javascript library created with the objective of loading config from JSON files with type checking, defaults and the ability to update the configuration file","archived":false,"fork":false,"pushed_at":"2021-08-18T01:00:29.000Z","size":68,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-18T21:17:54.733Z","etag":null,"topics":["config-load","js","library","ts"],"latest_commit_sha":null,"homepage":"","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/phaalonso.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}},"created_at":"2021-08-09T03:30:00.000Z","updated_at":"2021-11-17T00:03:32.000Z","dependencies_parsed_at":"2022-09-05T15:50:26.612Z","dependency_job_id":null,"html_url":"https://github.com/phaalonso/config-typing","commit_stats":null,"previous_names":["phaalonso/configurator"],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/phaalonso%2Fconfig-typing","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/phaalonso%2Fconfig-typing/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/phaalonso%2Fconfig-typing/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/phaalonso%2Fconfig-typing/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/phaalonso","download_url":"https://codeload.github.com/phaalonso/config-typing/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250540941,"owners_count":21447427,"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-load","js","library","ts"],"created_at":"2024-10-02T19:08:02.290Z","updated_at":"2025-04-24T01:10:21.721Z","avatar_url":"https://github.com/phaalonso.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Config validator\n\n[Npm package](https://www.npmjs.com/package/config-validation)\n\nA library created with the objective to facilitate creating configurating configuration that are stored in JSON files. It's uses a schema defined by the user, that the loaded json file needs to have otherside the loading of the file will fail as an \"Config error\".\n\n## Important\nIn the moment this library is in pre-release, so be careful when to use it. There can be lots of bugs or some problems that needs to be fixed.\n\n## Reasong\nAn alternative of [Convict](https://www.npmjs.com/package/convict) written in Typescript, the primary reason of this library is the need of dynamically updating the configuration file in  some of my projects (yeah, it has it's owns risk but I need to do it :/ and take care of all possible errors)\n\n## How to use\nSetup an configuration file anywhere in your machine (be certain that the application can read the file), and use it's path in configurator\n\nExample:\n```ts\nimport { configurator } from \"config-validation\";\nimport path from 'path';\n\nconst Configurator = configurator({\n\tdatabaseUrl: {\n\t\tdescription: 'Database url',\n\t\ttype: 'string',\n\t\trequired: true,\n\t},\n\tinsert_invertal: {\n\t\tdescription: 'Bach insert interval used for buffer cleaning',\n\t\ttype: 'number',\n\t\trequired: true,\n\t},\n\tserver: {\n\t\tport: {\n\t\t\tdescription: 'The server port',\n\t\t\ttype: 'number',\n\t\t\tdefault: 3333,\n\t\t}\n\t}\n});\n\n// Load configs from the file config.json\nConfigurator.load(path.join(__dirname, 'config.json'));\n\nconsole.log(Configurator.get('databaseUrl'));\n\n// Update the config value\nConfigurator.set('databaseUrl', 'Another url')\n\nconsole.log(Configurator.get('databaseUrl'));\n\n// Write the config changes to the file\nConfigurator.updateConfigFile();\n```\n\n## Todo\n- [X] Ability to the user add new types\n- [X] Method that permit changing an config\n- [X] Updating the configuration file\n- [X] Sub-configs\n- [ ] Fix set and get to work with Sub-configs\n- [ ] Implementing unit test's\n\n## Inspiration\n- [Convict](https://www.npmjs.com/package/convict)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fphaalonso%2Fconfig-typing","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fphaalonso%2Fconfig-typing","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fphaalonso%2Fconfig-typing/lists"}