{"id":18382344,"url":"https://github.com/centeredge/runtime-mock-routes","last_synced_at":"2026-01-28T05:58:20.177Z","repository":{"id":40545253,"uuid":"294813154","full_name":"CenterEdge/runtime-mock-routes","owner":"CenterEdge","description":"Define mock http service routes and responses at runtime","archived":false,"fork":false,"pushed_at":"2024-11-06T21:54:18.000Z","size":222,"stargazers_count":0,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-14T04:08:32.221Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"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/CenterEdge.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}},"created_at":"2020-09-11T21:12:15.000Z","updated_at":"2024-11-06T21:36:08.000Z","dependencies_parsed_at":"2024-12-24T06:11:43.493Z","dependency_job_id":"f6522360-4e89-419a-859c-98f484c28be5","html_url":"https://github.com/CenterEdge/runtime-mock-routes","commit_stats":{"total_commits":28,"total_committers":5,"mean_commits":5.6,"dds":0.5714285714285714,"last_synced_commit":"7d161db9988c4bf4aa40e2b682cd1e78c92bd6b6"},"previous_names":[],"tags_count":19,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CenterEdge%2Fruntime-mock-routes","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CenterEdge%2Fruntime-mock-routes/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CenterEdge%2Fruntime-mock-routes/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CenterEdge%2Fruntime-mock-routes/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/CenterEdge","download_url":"https://codeload.github.com/CenterEdge/runtime-mock-routes/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248819404,"owners_count":21166477,"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-06T01:04:36.040Z","updated_at":"2026-01-28T05:58:20.128Z","avatar_url":"https://github.com/CenterEdge.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Runtime-Mock-Routes\n\nRuntime-Mock-Routes is a nodejs application for defining parameterized route and response bodies. This is ideal for mocking 3rd party services.\n\n## Installation\n\nUse the package manager [npm](https://www.npmjs.com/) or [yarn](https://yarnpkg.com/) to install Runtime-Mock-Routes.\n\n```bash\nnpm install -g @centeredgesoft/runtime-mock-routes\n```\n\n## Usage\n\n```bash\nruntime-mock-routes -p 8080 -s ./seed.json\n```\n\nAll command line options are optional. If a seed file is supplied, it must be one of the following\n* a json file that matches a `RuntimeRequestCollection`\n* a js file with a default export of type `RuntimeRequestCollection`\n* a js file with a default export of a function that returns a `RuntimeRequestCollection`\n\n```typescript\ntype SupportedMethodsType = ['GET', 'POST', 'PUT', 'PATCH', 'DELETE'];\nconst SupportedMethodsColection: SupportedMethodsType = ['GET', 'POST', 'PUT', 'PATCH', 'DELETE'];\ntype SupportedMethod = SupportedMethodsType[number];\n\nexport interface RuntimeRequestMethodBody {\n    body: any;\n    status?: any;\n    headers?: Record\u003cstring, string\u003e;\n}\n\nexport type RuntimeRequestMethodBodyCollection = Partial\u003cRecord\u003cSupportedMethod, RuntimeRequestMethodBody\u003e\u003e;\n\nexport interface RuntimeRequestBody {\n    path: string;\n    methods: RuntimeRequestMethodBodyCollection;\n}\n\nexport interface RuntimeRequestCollection {\n    [path: string]: RuntimeRequestBody;\n}\n```\n\nFor example:\n```JSON\n{\n    \"/test\":{\n        \"path\":\"/test\",\n        \"methods\":{\n            \"GET\": {\n                \"body\": {},\n                \"status\": 200,\n                \"headers\": {\n                    \"X-Custom-Header\": \"yes\"\n                }\n            }\n        }\n    }\n}\n```\n\nThe following environment variables can also be used in place of command line options\n\n```\nRUNTIME_MOCK_ROUTES_PORT=8080\nRUNTIME_MOCK_ROUTES_FILE_PATH=/seed.json\n```\n\nRoute parameters are specified in path via a colon followed by the parameter name.\n`'/users/:id'`\n\nTemplate strings that are compatible with [handlebars](https://handlebarsjs.com/) can be used for the `body` property of a `RuntimeRequestMethodBody`. The application will use path and query params as data for the tempalte. This application makes use of [faker](https://www.npmjs.com/package/faker) and [chance](https://www.npmjs.com/package/chance) as Handlebars Helpers.\n\n```\n{{params.\u003cpath-param-name\u003e}} {{query.\u003cquery-param-name\u003e}} \n{{body.\u003cpost-body-property\u003e}}\n{{headers.\u003cheader-property-name\u003e}}\n{{ faker \"lorem.words\" 5}} {{ chance \"guid\"}}\n```\n\nIf the rendered template is valid JSON, the response will be of type `application/json`.\n\nAlso, be aware that instead of a direct JSON response, the body can also be a function that takes in a `RequestParameters` and returns a body response. The response will still be processed through handlebars.\n\n### Routes\n* `GET /` returns all of the currently defined routes \n* `POST /` Takes a `RuntimeRequestBody` and adds it to the collection or updates the existing entry if it exists.\n* `PUT /` Takes a `RuntimeRequestCollection` and replaces the current collection.\n* `[GET,POST,PUT,PATCH,DELETE] /*` The result of retrieving an entry in the collection, 404 otherwise\n* `DELETE /?path=\u003cpath\u003e` Deletes items from the collection\n\n## Contributing\nPull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.\n\nPlease make sure to add/update tests as appropriate.\n\n## License\n[MIT](https://choosealicense.com/licenses/mit/)","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcenteredge%2Fruntime-mock-routes","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcenteredge%2Fruntime-mock-routes","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcenteredge%2Fruntime-mock-routes/lists"}