{"id":20052716,"url":"https://github.com/ryosukecla/mockingcat","last_synced_at":"2025-03-02T08:44:48.457Z","repository":{"id":57300191,"uuid":"142857858","full_name":"RyosukeCla/mockingcat","owner":"RyosukeCla","description":"Build a mock api server with zero-conf at lightning speed","archived":false,"fork":false,"pushed_at":"2018-08-02T14:33:53.000Z","size":229,"stargazers_count":3,"open_issues_count":2,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-02-14T14:18:41.354Z","etag":null,"topics":["fastify","mock","nodejs","server","zero-configuration","zeroconf"],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/mockingcat","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/RyosukeCla.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-07-30T09:58:58.000Z","updated_at":"2018-10-08T17:05:00.000Z","dependencies_parsed_at":"2022-09-14T01:42:37.302Z","dependency_job_id":null,"html_url":"https://github.com/RyosukeCla/mockingcat","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RyosukeCla%2Fmockingcat","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RyosukeCla%2Fmockingcat/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RyosukeCla%2Fmockingcat/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RyosukeCla%2Fmockingcat/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/RyosukeCla","download_url":"https://codeload.github.com/RyosukeCla/mockingcat/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":241482066,"owners_count":19969847,"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":["fastify","mock","nodejs","server","zero-configuration","zeroconf"],"created_at":"2024-11-13T12:18:58.191Z","updated_at":"2025-03-02T08:44:48.424Z","avatar_url":"https://github.com/RyosukeCla.png","language":"JavaScript","readme":"# Mockingcat [![Build Status](https://travis-ci.org/RyosukeCla/mockingcat.svg?branch=master)](https://travis-ci.org/RyosukeCla/mockingcat)\n\n\u003e Build a mock api server with zero-conf at lightning speed\n\n## Getting started\n### #1 setup\ninstall mockingcat (or use npx)\n```\n$ npm i -g mockingcat\n# or\n$ npm i -D mockingcat\n```\n\nmake `mock` dir to project path\n```\n$ mkdir mock\n```\n\n### #2 start mockingcat\n```\n$ mockingcat\n# or\n$ npx mockingcat\n```\n\n### #3 make mock api - 1\nmake file `mock/get.js`\n```\n$ touch mock/get.js\n```\n\nnow, you can access to mock/get\n```\n$ curl http://localhost:8090/mock/get\n\u003e {\"message\":\"not implemented yet\"}\n```\n\nnext, implement `mock/get.js`\n```js\nmodule.exports = {\n  method: 'GET',\n  handler (request, reply) {\n    reply.send({ message: 'hello, world!' })\n  }\n}\n```\n\naccess to mock/get\n```\n$ curl http://localhost:8090/mock/get\n\u003e {\"message\":\"hello, world!\"}\n```\n\n### #4 make mock api - 2\nnext, make `mock/user/_id.js`, and append this\n```js\nmodule.exports = {\n  method: 'GET',\n  handler (request, reply) {\n    reply.send(request.params)\n  }\n}\n```\n\nyou can access to mock/user/_id\n```\n$ curl http://localhost:8090/mock/user/hello\n\u003e {\"id\": \"hello\"}\n```\n\n## Detail\n### config (default)\n`mockingcat.config.js`\n```js\nmodule.exports = {\n  port: 8090,\n  srcDir: './mock',\n  baseUrl: '/mock',\n  verbose: true,\n  middlewares: [], // fastify middleware\n  ignore: [/node_modules/]\n}\n```\n\n### mock file (default)\n- module.exports: `{ fastify route options }` or `Array\u003c{ fastify route options }\u003e`\n```js\nmodule.exports = {\n  method: 'GET',\n  url: baseUrl + mockFilepath\n  handler (request, reply) {\n    reply.send({ message: 'not implemented yet' })\n  }\n}\n```\nyou can define mock file as fastify route option.\n\n- [DOC: fastify route options](https://github.com/fastify/fastify/blob/master/docs/Routes.md#full-declaration)\n\n### CLI\n```\n$ mockingcat --help\n\nMockingcat\n  --help     (-h)\n  --version  (-v)\n  --port     (-p) : 8090\n  --srcdir   (-s) : ./mock\n  --baseurl  (-b) : /mock\n  --verbose  (-v) : true\n```\n\n### Examples\n- [example](./example)\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fryosukecla%2Fmockingcat","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fryosukecla%2Fmockingcat","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fryosukecla%2Fmockingcat/lists"}