{"id":28955728,"url":"https://github.com/seancheung/mockit","last_synced_at":"2025-06-23T20:09:43.590Z","repository":{"id":32971327,"uuid":"141416197","full_name":"seancheung/mockit","owner":"seancheung","description":"Http API mock for frontend development","archived":false,"fork":false,"pushed_at":"2022-07-21T09:43:26.000Z","size":3255,"stargazers_count":0,"open_issues_count":16,"forks_count":0,"subscribers_count":1,"default_branch":"dev","last_synced_at":"2025-05-31T09:50:54.507Z","etag":null,"topics":["api","fake","http","mock","restful","route"],"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/seancheung.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":"2018-07-18T09:57:20.000Z","updated_at":"2020-11-08T16:45:34.000Z","dependencies_parsed_at":"2022-08-07T19:15:27.425Z","dependency_job_id":null,"html_url":"https://github.com/seancheung/mockit","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/seancheung/mockit","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/seancheung%2Fmockit","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/seancheung%2Fmockit/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/seancheung%2Fmockit/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/seancheung%2Fmockit/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/seancheung","download_url":"https://codeload.github.com/seancheung/mockit/tar.gz/refs/heads/dev","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/seancheung%2Fmockit/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":261548748,"owners_count":23175499,"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":["api","fake","http","mock","restful","route"],"created_at":"2025-06-23T20:09:40.731Z","updated_at":"2025-06-23T20:09:43.579Z","avatar_url":"https://github.com/seancheung.png","language":"JavaScript","readme":"# mockit\n\n[![Dist Build][travis-dist]][travis-url]\n[![Dev Build][travis-dev]][travis-url]\n\nHttp API mock for frontend development\n\n[travis-dist]: https://img.shields.io/travis/seancheung/mockit/dist.svg?label=dist\n[travis-dev]: https://img.shields.io/travis/seancheung/mockit/dev.svg?label=dev\n[travis-url]: https://travis-ci.org/seancheung/mockit\n\n## Install\n\n```bash\nnpm i -g mockitjs\n```\n\n## Usage\n\n```bash\nmockit -h\n```\n\nOutput:\n\n```text\nUsage: mockit [options] [config]\n\noptions:\n   -H, --host=\u003chost\u003e       host name\n   -P, --port=\u003cport\u003e       port number\n   -S, --ssl               enable https\n       --http2             enable http2\n       --template=\u003cpath\u003e   template file path\n       --routes=\u003cpath\u003e     routes file path\n       --watch             enable routes file watch\n       --persist=\u003cpath\u003e    dump file path\n   -C, --cert=\u003cpath\u003e       ssl cert file path\n   -K, --key=\u003cpath\u003e        ssl key file path\n   -O, --open              open browser\n       --verbose           output verbose info\n   -h, --help              show this help\n```\n\nQuick start:\n\n```bash\nmockit\n```\n\nStart from config file\n\n```bash\nmockit ./config.yml\nmockit ./config.json\n```\n\n## Config\n\n### App\n\nconfig.yml\n\n```yaml\n# 0.0.0.0 to listen from anywhere\nhost: \"127.0.0.1\"\n# 0 to assign an available port\nport: 0\n# enable http2 support(requires ssl)\nhttp2: false\nssl:\n  # enable ssl support\n  enabled: false\n  cert: \"/path/to/cert/file\"\n  key: \"/path/to/key/file\"\n# enable verbose debug\ndebug: true\n# enable request logging\nlogger:\n  enabled: true\n  # morgan types: combined|common|dev|short|tiny\n  type: \"combined\"\ndashboard:\n  # dashboard base url\n  baseUrl: \"/dashboard\"\n  # template config(object) or path to template file(absolute or relative to this config file)\n  template: \"template.yml\"\nrouter:\n  # enable CORS\n  cors: true\n  # routes config(object) or path to routes file(absolute or relative to this config file)\n  routes: \"routes.yml\"\n```\n\nconfig.json\n\n```json\n{\n  \"host\": \"127.0.0.1\",\n  \"port\": 0,\n  \"http2\": false,\n  \"ssl\": {\n    \"enabled\": false,\n    \"cert\": \"/path/to/cert/file\",\n    \"key\": \"/path/to/key/file\"\n  },\n  \"debug\": true,\n  \"logger\": {\n    \"enabled\": true,\n    \"type\": \"combined\"\n  },\n  \"dashboard\": {\n    \"baseUrl\": \"/dashboard\",\n    \"template\": \"template.yml\"\n  },\n  \"router\": {\n    \"cors\": true,\n    \"routes\": \"routes.yml\"\n  }\n}\n```\n\n### Template\n\ntemplate.yml\n\n```yaml\n# http methods\nmethods:\n  - \"GET\"\n  - \"HEAD\"\n  - \"POST\"\n  - \"PUT\"\n  - \"DELETE\"\n  - \"CONNECT\"\n  - \"OPTIONS\"\n  - \"TRACE\"\n  - \"PATCH\"\n  # catch all\n  - \"ALL\"\n# http status codes and descriptions\ncodes:\n  \"100\": \"Continue\"\n  \"101\": \"Switching Protocols\"\n  \"102\": \"Processing\"\n  \"200\": \"OK\"\n  \"201\": \"Created\"\n  \"202\": \"Accepted\"\n  \"203\": \"Non-Authoritative Information\"\n  \"204\": \"No Content\"\n  \"205\": \"Reset Content\"\n  \"206\": \"Partial Content\"\n  \"207\": \"Multi-Status\"\n  \"208\": \"Already Reported\"\n  \"226\": \"IM Used\"\n  \"300\": \"Multiple Choices\"\n  \"301\": \"Moved Permanently\"\n  \"302\": \"Found\"\n  \"303\": \"See Other\"\n  \"304\": \"Not Modified\"\n  \"305\": \"Use Proxy\"\n  \"306\": \"Switch Proxy\"\n  \"307\": \"Temporary Redirect\"\n  \"308\": \"Permanent Redirect\"\n  \"400\": \"Bad Request\"\n  \"401\": \"Unauthorized\"\n  \"402\": \"Payment Required\"\n  \"403\": \"Forbidden\"\n  \"404\": \"Not Found\"\n  \"405\": \"Method Not Allowed\"\n  \"406\": \"Not Acceptable\"\n  \"407\": \"Proxy Authentication Required\"\n  \"408\": \"Request Timeout\"\n  \"409\": \"Conflict\"\n  \"410\": \"Gone\"\n  \"411\": \"Length Required\"\n  \"412\": \"Precondition Failed\"\n  \"413\": \"Payload Too Large\"\n  \"414\": \"URI Too Long\"\n  \"415\": \"Unsupported Media Type\"\n  \"416\": \"Range Not Satisfiable\"\n  \"417\": \"Expectation Failed\"\n  \"418\": \"I'm a teapot\"\n  \"421\": \"Misdirected Request\"\n  \"422\": \"Unprocessable Entity\"\n  \"423\": \"Locked\"\n  \"424\": \"Failed Dependency\"\n  \"425\": \"Unordered Collection\"\n  \"426\": \"Upgrade Required\"\n  \"428\": \"Precondition Required\"\n  \"429\": \"Too Many Requests\"\n  \"431\": \"Request Header Fields Too Large\"\n  \"444\": \"No Response\"\n  \"449\": \"Retry With\"\n  \"450\": \"Blocked by Windows Parental Controls\"\n  \"451\": \"Unavailable For Legal Reasons\"\n  \"499\": \"Client Closed Request\"\n  \"500\": \"Internal Server Error\"\n  \"501\": \"Not Implemented\"\n  \"502\": \"Bad Gateway\"\n  \"503\": \"Service Unavailable\"\n  \"504\": \"Gateway Timeout\"\n  \"505\": \"HTTP Version Not Supported\"\n  \"506\": \"Variant Also Negotiates\"\n  \"507\": \"Insufficient Storage\"\n  \"509\": \"Bandwidth Limit Exceeded\"\n  \"510\": \"Not Extended\"\n  \"511\": \"Network Authentication Required\"\n# response types\nmime:\n  - \"application/json\"\n  - \"application/x-www-form-urlencoded\"\n  - \"application/xhtml+xml\"\n  - \"application/xml\"\n  - \"multipart/form-data\"\n  - \"text/css\"\n  - \"text/csv\"\n  - \"text/html\"\n  - \"text/json\"\n  - \"text/plain\"\n  - \"text/xml\"\n```\n\ntemplate.json\n\n```json\n{\n  \"methods\": [\n    \"GET\",\n    \"HEAD\",\n    \"POST\",\n    \"PUT\",\n    \"DELETE\",\n    \"CONNECT\",\n    \"OPTIONS\",\n    \"TRACE\",\n    \"PATCH\"\n  ],\n  \"codes\": {\n    \"100\": \"Continue\",\n    \"101\": \"Switching Protocols\",\n    \"102\": \"Processing\",\n    \"200\": \"OK\",\n    \"201\": \"Created\",\n    \"202\": \"Accepted\",\n    \"203\": \"Non-Authoritative Information\",\n    \"204\": \"No Content\",\n    \"205\": \"Reset Content\",\n    \"206\": \"Partial Content\",\n    \"207\": \"Multi-Status\",\n    \"208\": \"Already Reported\",\n    \"226\": \"IM Used\",\n    \"300\": \"Multiple Choices\",\n    \"301\": \"Moved Permanently\",\n    \"302\": \"Found\",\n    \"303\": \"See Other\",\n    \"304\": \"Not Modified\",\n    \"305\": \"Use Proxy\",\n    \"306\": \"Switch Proxy\",\n    \"307\": \"Temporary Redirect\",\n    \"308\": \"Permanent Redirect\",\n    \"400\": \"Bad Request\",\n    \"401\": \"Unauthorized\",\n    \"402\": \"Payment Required\",\n    \"403\": \"Forbidden\",\n    \"404\": \"Not Found\",\n    \"405\": \"Method Not Allowed\",\n    \"406\": \"Not Acceptable\",\n    \"407\": \"Proxy Authentication Required\",\n    \"408\": \"Request Timeout\",\n    \"409\": \"Conflict\",\n    \"410\": \"Gone\",\n    \"411\": \"Length Required\",\n    \"412\": \"Precondition Failed\",\n    \"413\": \"Payload Too Large\",\n    \"414\": \"URI Too Long\",\n    \"415\": \"Unsupported Media Type\",\n    \"416\": \"Range Not Satisfiable\",\n    \"417\": \"Expectation Failed\",\n    \"418\": \"I'm a teapot\",\n    \"421\": \"Misdirected Request\",\n    \"422\": \"Unprocessable Entity\",\n    \"423\": \"Locked\",\n    \"424\": \"Failed Dependency\",\n    \"425\": \"Unordered Collection\",\n    \"426\": \"Upgrade Required\",\n    \"428\": \"Precondition Required\",\n    \"429\": \"Too Many Requests\",\n    \"431\": \"Request Header Fields Too Large\",\n    \"444\": \"No Response\",\n    \"449\": \"Retry With\",\n    \"450\": \"Blocked by Windows Parental Controls\",\n    \"451\": \"Unavailable For Legal Reasons\",\n    \"499\": \"Client Closed Request\",\n    \"500\": \"Internal Server Error\",\n    \"501\": \"Not Implemented\",\n    \"502\": \"Bad Gateway\",\n    \"503\": \"Service Unavailable\",\n    \"504\": \"Gateway Timeout\",\n    \"505\": \"HTTP Version Not Supported\",\n    \"506\": \"Variant Also Negotiates\",\n    \"507\": \"Insufficient Storage\",\n    \"509\": \"Bandwidth Limit Exceeded\",\n    \"510\": \"Not Extended\",\n    \"511\": \"Network Authentication Required\"\n  },\n  \"mime\": [\n    \"application/json\",\n    \"application/x-www-form-urlencoded\",\n    \"application/xhtml+xml\",\n    \"application/xml\",\n    \"multipart/form-data\",\n    \"text/css\",\n    \"text/csv\",\n    \"text/html\",\n    \"text/json\",\n    \"text/plain\",\n    \"text/xml\"\n  ]\n}\n```\n\n### Routes\n\nSee [mockit-express](https://github.com/seancheung/mockit-express#config)\n\n## Integrate into Express\n\nSee [mockit-express](https://github.com/seancheung/mockit-express)\n\n## Integrate into Webpack\n\nWith dashboard(UI)\n\n```javascript\nconst mockit = require(\"mockit\");\n//...\nmodule.exports = {\n  //...\n  devServer: {\n    after: function(app) {\n      mockit({\n        baseUrl: \"/dashboard\",\n        routes: \"/path/to/routes/file\",\n        watch: true\n      })(app);\n    }\n  }\n};\n```\n\nWithout dashboard(UI)\n\nSee [mockit-express](https://github.com/seancheung/mockit-express#integrate-into-webpack)\n\n## Test\n\n```bash\nnpm test\n```\n\n## License\n\nSee [License](https://github.com/seancheung/mockit/blob/master/LICENSE)\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fseancheung%2Fmockit","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fseancheung%2Fmockit","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fseancheung%2Fmockit/lists"}