{"id":16122480,"url":"https://github.com/orels1/puremock","last_synced_at":"2025-10-26T05:37:26.213Z","repository":{"id":73396663,"uuid":"154050620","full_name":"orels1/puremock","owner":"orels1","description":"A zero-dependency mock api server ⚡️","archived":false,"fork":false,"pushed_at":"2018-10-29T02:50:55.000Z","size":38,"stargazers_count":6,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-03-26T00:45:49.883Z","etag":null,"topics":["mock","nodejs","rest-api","zero-dependency"],"latest_commit_sha":null,"homepage":"","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/orels1.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-10-21T20:45:40.000Z","updated_at":"2023-01-27T12:49:21.000Z","dependencies_parsed_at":null,"dependency_job_id":"981a201d-abe7-4a41-a434-42bb1dc20822","html_url":"https://github.com/orels1/puremock","commit_stats":{"total_commits":15,"total_committers":1,"mean_commits":15.0,"dds":0.0,"last_synced_commit":"65a7d30ef6d780c798abd867bd4462da78d53b36"},"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/orels1%2Fpuremock","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/orels1%2Fpuremock/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/orels1%2Fpuremock/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/orels1%2Fpuremock/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/orels1","download_url":"https://codeload.github.com/orels1/puremock/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243925492,"owners_count":20369906,"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":["mock","nodejs","rest-api","zero-dependency"],"created_at":"2024-10-09T21:11:51.604Z","updated_at":"2025-10-26T05:37:26.091Z","avatar_url":"https://github.com/orels1.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003ch1 align=\"center\"\u003ePuremock\u003c/h1\u003e\n\u003cp align=\"center\"\u003e\n  \u003cstrong\u003e⚡️ A zero-dependency mock api server ⚡️\u003c/strong\u003e\u003cbr /\u003e\n\u003c/p\u003e\n\n\u003cp align=\"center\"\u003e\n  \u003ca href=\"https://www.npmjs.com/package/puremock\"\u003e\n    \u003cimg src=\"https://img.shields.io/npm/v/puremock.svg?style=flat-square\" /\u003e\n  \u003c/a\u003e\n  \u003ca href=\"https://www.npmjs.com/package/puremock\"\u003e\n    \u003cimg src=\"https://img.shields.io/npm/dm/puremock.svg?style=flat-square\" /\u003e\n  \u003c/a\u003e\n  \u003cimg src=\"https://img.shields.io/badge/zero-dependencies-blue.svg?style=flat-square\" /\u003e\n\u003c/p\u003e\n\n\u003cp align=\"center\"\u003e\n  \u003csub\u003eBuilt with ❤︎ by\n  \u003ca href=\"https://twitter.com/orels1_\"\u003eorels1\u003c/a\u003e\n  \u003c/sub\u003e\n\u003c/p\u003e\n\n## Motivation\n\nHacktoberfest, mainly, but also just a search for a package like this that took me more than an hour and ultimately pointed me to Mockoon (which is great, btw, [check it out](https://mockoon.com/)). But I figured I should make this too, since I have a soft spot for cute zero-dep tools, so here we are. Hope you'll enjoy using it as much, as I did developing it.\n\n## Installation\n\n```shell\n# with npm\nnpm i -g puremock\n\n#with yarn\nyarn global add puremock\n```\n\n## Usage\n\n### Create a mock file\n\nBy default puremock will look for `mockApi.json` in the project root. But you can also supply a different path (see below).\n\n```json\n{\n  \"GET /\": {\n    \"response\": {\n      \"status\": \"ok\"\n    }\n  },\n  \"GET /error\": {\n    \"status\": 503,\n    \"header\": {\n      \"x-powered-by\": \"mock-api-server\"\n    },\n    \"response\": {\n      \"error\": \"Internal Server Error\"\n    }\n  },\n  \"GET /articles/:name\": {\n    \"response\": {\n      \"title\": \"Foobar\"\n    }\n  }\n}\n```\n\nThat's about it as far as configuration goes. You can supply any kind of HTTP method, set response codes and headers.\n\nPath params are supported (with multiple levels), so you can have endpoints like `/root/:param1/:param2` or `/root/exact/:param1` and so on. Useful when you have a bunch of dynamic IDs your app requests, but you don't care if the same thing is being returned.\n\nCheck `example.json` for references.\n\nDefault response code is 200, and the `Content-Type` header is set to `application/json`.\n\n### Start the server\n\nBy default the server will start at `localhost:3000`.\n\n```shell\n# uses a mockApi.json in the project root\npuremock\n\n# you can pass a custom path to a mock file\npuremock ./mocks/api.json\n\n# port customization is also supported\npuremock --port 4000\n```\n\n### Contribute\n\nThere are still things we can add while staying lightweight and zero-dependency:\n\n- [x] Add a mock file hot-reload\n- [x] Support for dynamic urls (i.e. `/posts/:id)\n- [ ] Add a set of prebuilt error responses so users can just supply `status: 503) to get a meaningful response object without defining it\n- [ ] Improve the watcher logic (it fails from time to time so I have a bunch of retries there)\n\nThe package is auto-published with the latest tag in the package.json when merged into `master`.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Forels1%2Fpuremock","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Forels1%2Fpuremock","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Forels1%2Fpuremock/lists"}