{"_id":"@amitwolfus/copycat","_rev":"2-fdad84e6f8b659ead2d5b72a58effe11","name":"@amitwolfus/copycat","dist-tags":{"latest":"1.1.0"},"versions":{"1.0.0":{"name":"@amitwolfus/copycat","version":"1.0.0","bin":{"copycat":"lib/cli.js"},"description":"A simple, declarative CLI to mock HTTP servers for development and testing purposes","main":"lib/index.ts","type":"module","types":"lib/index.d.js","scripts":{"dev":"ts-node src/cli.ts -f example-routes.json","start":"node lib/cli.js -f ./example-routes.json","build":"npm run clean && tsc && chmod +x ./lib/cli.js","clean":"rm -rf ./lib || 1","prepare":"npm run build","format":"prettier --write \"src/**/*.ts\""},"author":{"name":"Amit Wolfus"},"license":"ISC","dependencies":{"@faker-js/faker":"^7.6.0","fastify":"^4.14.1","handlebars":"^4.7.7","minimist":"^1.2.8","nanoid":"^4.0.1"},"devDependencies":{"@tsconfig/esm":"^1.0.2","@tsconfig/node16":"^1.0.3","@tsconfig/node18":"^1.0.1","@tsconfig/recommended":"^1.0.2","@types/minimist":"^1.2.2","@types/node":"^18.15.3","prettier":"^2.8.4","ts-node":"^10.9.1","typescript":"^4.9.5"},"gitHead":"90c38e9d276a541a9d3c4900041725401ff0216f","_id":"@amitwolfus/copycat@1.0.0","_nodeVersion":"18.12.1","_npmVersion":"8.19.2","dist":{"integrity":"sha512-gcsjIoIjwOTRsnntKwRFRd74u8nKl07De0bVjknazsaovDucgfFArolG67fL4CsaTCoB+CGkxZt3pmKCi3c46A==","shasum":"f8269a07811dd662e6f0b1d025b80ed4fa6b287b","tarball":"https://registry.npmjs.org/@amitwolfus/copycat/-/copycat-1.0.0.tgz","fileCount":45,"unpackedSize":75181,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQDXvxGTjOu6eYLj8zOOtE3ueG45a36s6H+y2qeGfjIZPAIhAJ2yz6d4jp0b1ylWztv90+fDmB56XKqjitGQTTUc05dI"}],"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJkJYaiACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmoSCRAAorBPZ7JuzABq1sTDq9LvmIU/OK9DzEWpk3WaXGrmqdPABRn3\r\ngzOhxNb4vBPG1GCt2R1CBi6ECBoQFh0GjEAPCsOS7EACmLX/EPt9pDYG31Pv\r\nO4tN4Cf/C6xHhnA082hx6xU2UhCxXpwDSQ15DDugZj/gXUcJGauDiDoNDSfs\r\nuWC+jML04xDaB7zjJx6oJQ6EEqhap75fiM4qW8Wg9uH9idiusyS0ejxXwR+j\r\nZyDt1QpEG5EpMVda0gKs28Hp1EhIVI3z/swPQ3q1JsGTJZidEkRVcphCKQOq\r\nuVH1BuEKYEZSqT+Fj1j+ljt8kYU92pydWrWS5Ty39GdFLYZSkQ+8PUcb1GaS\r\n+gdcOKwvgS3Bt2ZsDQxpAEa1HbBH5hp3050RcRgKspf2OFG4fgYQpw2c57m0\r\nFqwljjvwrlnZmJzVhDot0W78Tz+M4k4XYTRqVun56l8UdsWmkvNne8QLr8nc\r\n93RMfUCOA7+yH28bhkfBmKv1DsZAI94Xz7bDKQbB3pQMo9lG9lz3BzySibEv\r\nTu5m+bvhsMnh10c4fSKWgY5wIhUh59PTSynSFl7TBMfLBITgo2IbXSDuUEHi\r\nRO9mmgDUFi6SP2444xBiyNxkJRReMZvmm1HpYsATA4gRRL3n5F8Fa/3csf1q\r\nQTKN6pppcapLMx73mEgX8g8sEtc13g+RWYE=\r\n=+OIe\r\n-----END PGP SIGNATURE-----\r\n"},"_npmUser":{"name":"amitwolfus","email":"amitwolfus@gmail.com"},"directories":{},"maintainers":[{"name":"amitwolfus","email":"amitwolfus@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/copycat_1.0.0_1680180898668_0.8778511945301344"},"_hasShrinkwrap":false},"1.0.1":{"name":"@amitwolfus/copycat","version":"1.0.1","bin":{"copycat":"lib/cli.js"},"description":"A simple, declarative CLI to mock HTTP servers for development and testing purposes","main":"lib/index.ts","type":"module","types":"lib/index.d.js","repository":{"type":"git","url":"git+https://github.com/AmitWolfus/copycat.git"},"scripts":{"dev":"ts-node src/cli.ts -f example-routes.json","start":"node lib/cli.js -f ./example-routes.json","build":"npm run clean && tsc && chmod +x ./lib/cli.js","clean":"rm -rf ./lib || 1","prepare":"npm run build","format":"prettier --write \"src/**/*.ts\""},"author":{"name":"Amit Wolfus"},"license":"ISC","dependencies":{"@faker-js/faker":"^7.6.0","fastify":"^4.14.1","handlebars":"^4.7.7","minimist":"^1.2.8","nanoid":"^4.0.1"},"devDependencies":{"@tsconfig/esm":"^1.0.2","@tsconfig/node16":"^1.0.3","@tsconfig/node18":"^1.0.1","@tsconfig/recommended":"^1.0.2","@types/minimist":"^1.2.2","@types/node":"^18.15.3","prettier":"^2.8.4","ts-node":"^10.9.1","typescript":"^4.9.5"},"gitHead":"e02cf3217f270a56dc4b4816fbd1d573e25791b9","bugs":{"url":"https://github.com/AmitWolfus/copycat/issues"},"homepage":"https://github.com/AmitWolfus/copycat#readme","_id":"@amitwolfus/copycat@1.0.1","_nodeVersion":"18.12.1","_npmVersion":"8.19.2","dist":{"integrity":"sha512-zVu9Ck9fn+TbAT7h45tCOEZAS3RBpuKsXqex5XuXnedEhQWxpc1tdc27Omc43WFyglm7E3kpHMwVkNBgnyUWAw==","shasum":"453d66f937c5c52e5647e10100fd3ac128bed96d","tarball":"https://registry.npmjs.org/@amitwolfus/copycat/-/copycat-1.0.1.tgz","fileCount":45,"unpackedSize":75274,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCICDgPFMBEmxnkR/sK0tI66KJYArUtZ9wl7YokYbswSVwAiBJwDoDFcZGTXuY6a1xiAyGUo+LhrOSzIOprYB+pb8Vzw=="}],"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJkJYvhACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2Vmr13xAAn1TF71FhfT4ZUeDO1i54CF/10VzkzKk4JiI+8BrpCbI5Bp+9\r\nNgDLeaB/M2tiWziqwh0k/OOh+yfFh5BLYjazcwbNb6aiTgHA7gRAUdOBwFL2\r\nWdRrLelWOdkaxtm6dLCtuqkJOUi2rhuXGAqiDKdqcLSkFMf0G0aHfpZvyiKQ\r\nJSe+qe8geYS40hhJkGRbPTozhtF3sYHrgL8AtlRxNN2HyJ6dRo5U4cFxvIOl\r\nu+8+/cCCUJET7Xx6B1Nz+P7q6yJOoC+2QGjkkeUw/UhR0AaU5/d7IHvVFpv4\r\nKRYJDGQ/vuXKU2Ubd8fL9NDAfPYUV/LNGXYwtXAnbLVooASgiyl1cEk5cRWH\r\nDZ1CaC2pf80UMj5zzyyiurndlJyd3x6cN4/7tBMxtb+E9+ZrNa0+3rbwqF7J\r\ngoohE1GlBVjCBjtKC8fZwAvVG3InNofy9z4cOo54HB/xBFv0DU1R5nf6O7vh\r\nYCdo+bmgJQwDNLQWZdBmv0bNycbOsU3wK0ietCGuKOYQzaA++yEPak4NzcOb\r\neXkfNBXflYyXRlOz6ODlXEhyk4pby7qXmfos3GYZl8XM6oM0nOr+hlOc2TJh\r\n0jHhMnyUu7Fgr9L323EGIw3L5YfAwksdqTcVnRZgEWGA5+5xt9+H5TOzFcjB\r\ncJ/cqwC18T15qywxtgy5whuYmbDVRhm2l2Q=\r\n=Syeb\r\n-----END PGP SIGNATURE-----\r\n"},"_npmUser":{"name":"amitwolfus","email":"amitwolfus@gmail.com"},"directories":{},"maintainers":[{"name":"amitwolfus","email":"amitwolfus@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/copycat_1.0.1_1680182241164_0.010964309938621186"},"_hasShrinkwrap":false},"1.1.0":{"name":"@amitwolfus/copycat","version":"1.1.0","bin":{"copycat":"lib/cli.js"},"description":"A simple, declarative CLI to mock HTTP servers for development and testing purposes","main":"lib/index.ts","type":"module","types":"lib/index.d.js","repository":{"type":"git","url":"git+https://github.com/AmitWolfus/copycat.git"},"scripts":{"dev":"ts-node src/cli.ts -f example-routes.json","start":"node lib/cli.js -f ./example-routes.json","build":"npm run clean && tsc && chmod +x ./lib/cli.js","clean":"rm -rf ./lib || 1","prepare":"npm run build","format":"prettier --write \"src/**/*.ts\""},"author":{"name":"Amit Wolfus"},"license":"ISC","dependencies":{"@faker-js/faker":"^7.6.0","fastify":"^4.14.1","handlebars":"^4.7.7","minimist":"^1.2.8","nanoid":"^4.0.1"},"devDependencies":{"@tsconfig/esm":"^1.0.2","@tsconfig/node16":"^1.0.3","@tsconfig/node18":"^1.0.1","@tsconfig/recommended":"^1.0.2","@types/minimist":"^1.2.2","@types/node":"^18.15.3","prettier":"^2.8.4","ts-node":"^10.9.1","typescript":"^4.9.5"},"gitHead":"d497d077db7fca92f8fc989b283217985760452b","bugs":{"url":"https://github.com/AmitWolfus/copycat/issues"},"homepage":"https://github.com/AmitWolfus/copycat#readme","_id":"@amitwolfus/copycat@1.1.0","_nodeVersion":"18.12.1","_npmVersion":"8.19.2","dist":{"integrity":"sha512-hOSuZdqhIap/qjsaCbS6SCBNUixiaXxe6VifSUYnuL4mv2hQXyAWH/lxMrC44uCOOcMmRj7sk3PpiofIA8RDbQ==","shasum":"c08e1255a89eb1d886ed2c3ab897042bb2de5437","tarball":"https://registry.npmjs.org/@amitwolfus/copycat/-/copycat-1.1.0.tgz","fileCount":45,"unpackedSize":75360,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCICpasUZeNN/0sbntReQL2PT32ERC0QxLf5eu7y1yfJ7ZAiEAgZUeiqEC/xESCZ2vTCfsCXNLUjja51bburCdqacukEs="}]},"_npmUser":{"name":"amitwolfus","email":"amitwolfus@gmail.com"},"directories":{},"maintainers":[{"name":"amitwolfus","email":"amitwolfus@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/copycat_1.1.0_1687422848486_0.8573467720499468"},"_hasShrinkwrap":false}},"time":{"created":"2023-03-30T12:54:58.583Z","1.0.0":"2023-03-30T12:54:58.791Z","modified":"2023-06-22T08:34:08.868Z","1.0.1":"2023-03-30T13:17:21.324Z","1.1.0":"2023-06-22T08:34:08.761Z"},"maintainers":[{"name":"amitwolfus","email":"amitwolfus@gmail.com"}],"description":"A simple, declarative CLI to mock HTTP servers for development and testing purposes","author":{"name":"Amit Wolfus"},"license":"ISC","readme":"# copycat\n\nA simple, declarative CLI & framework to mock HTTP servers for development and testing purposes\n\n## Defining routes\n\nMock routes are defined in a declarative manner using JSON files, the root of the JSON should be an object where each property is a root route.\n\n### Simple Routes\n\nEach route can define HTTP method handlers using the following keys: \"GET\", \"POST\", \"DELETE\", \"PUT\", \"PATCH\" where the value of the property being the returned body for that route, for example:\n\n```json\n{\n  \"/orders\": {\n    \"GET\": {\n      \"orders\": [\n        {\n          \"id\": 123,\n          \"status\": \"completed\"\n        }\n      ]\n    }\n  }\n}\n```\n\nThe following JSON defines a route at /myFirstRoute that has a GET endpoint, the GET endpoint returns a fixed array of JSON object with the properties \"id\" and \"status\"\n\n### Parameterized routes\n\ncopycat uses fastify under the hood and supports route parameters, this can be used to support routes with unknown parameters, for example a GET by id:\n\n```json\n{\n  \"/orders/:id\": {\n    \"GET\": {\n      \"id\": 123,\n      \"status\": \"pending\"\n    }\n  }\n}\n```\n\n### Nested Routes\n\nIn addition to the HTTP Method properties, it is also possible to define nested routes, the resulting route will be a concatenation of the parent routes, for example the previous routes can be combined into the following definition:\n\n```json\n{\n  \"/orders\": {\n    \"GET\": {\n      \"orders\": [\n        {\n          \"id\": 123,\n          \"status\": \"completed\"\n        }\n      ]\n    },\n    \"/:id\": {\n      \"GET\": {\n        \"id\": 123,\n        \"status\": \"pending\"\n      }\n    }\n  }\n}\n```\n\n### Controlling the entire response\n\nThe previous examples use the simple syntax and define an object that represents the response, sometimes there is a need to control other aspects of the request like setting headers, http status or returning a response that isn't JSON.\n\nIn order to take control of the entire response, a route can be defined as an object that contains the property \"body\" as follows:\n\n```json\n{\n  \"/orders/:id\": {\n    \"PUT\": {\n      \"body\": {\n        \"message\": \"created\"\n      },\n      \"status\": 201\n    }\n  }\n}\n```\n\nA response supports the following properties:\n\n| Property    | Description                                                                                                                                            |\n| ----------- | ------------------------------------------------------------------------------------------------------------------------------------------------------ |\n| `status`    | Sets the response's HTTP status code, defaults to 200, can also be an error code                                                                       |\n| `headers`   | A json object with headers to set on the response, default headers are { \"content-type\": \"application/json\"} and will be merged with the given headers |\n| `condition` | Condition to check if route should run, see [Conditional routes](#conditional-routes)                                                                  |\n\n### Conditional routes\n\ncopycat allows routes to have conditions, this along with the possibility to provide an array of handlers to an endpoint allows for complex route handling and test cases.\n\nConditions are specified in javascript and have access to the body and url params, example:\n\n```json\n{\n  \"/orders/:id\": {\n    \"PUT\": [\n      {\n        \"condition\": \"params.id === 3\",\n        \"status\": 404,\n        \"body\": {\n          \"message\": \"order not found\"\n        }\n      },\n      {\n        \"condition\": \"body.status === 'completed'\",\n        \"status\": 400,\n        \"body\": {\n          \"message\": \"order can't be updated to completed status\"\n        }\n      },\n      {\n        \"body\": {\n          \"message\": \"updated\"\n        }\n      }\n    ]\n  }\n}\n```\n\n## Dynamic responses using templates\n\ncopycat support templates using [Handlebars](https://handlebarsjs.com/) templating engine, the template is provided with the request context including the body, route and query params, this allows for dynamic responses based on the request:\n\n```json\n{\n  \"/orders/:id\": {\n    \"GET\": {\n      \"id\": \"{{ params.id }}\",\n      \"status\": \"completed\"\n    }\n  }\n}\n```\n\n### Template helpers\n\ncopycat provides a few built-in handlebars helpers to allow generating random data\n\n#### nanoid\n\nAllows creation of random ids using the [nanoid](https://github.com/ai/nanoid) package, usage:\n\n```json\n{\n  \"/orders/:id\": {\n    \"GET\": {\n      \"id\": \"{{ nanoid . }}\",\n      \"status\": \"completed\"\n    }\n  }\n}\n```\n\n#### randomNumberId\n\nAllows creation of random ids made of numbers with a specified length:\n\n```json\n{\n  \"/orders/:id\": {\n    \"GET\": {\n      \"id\": \"{{ randomNumberId 4 }}\",\n      \"status\": \"completed\"\n    }\n  }\n}\n```\n\n#### faker\n\nAllows generating random data using [fakerjs](https://fakerjs.dev/), all methods from fakerjs are supported, usage is as follows:\n\n`\"{{ faker  '<namespace>.<function>'}}`\n\nThe following example will return a person with a random name and address:\n\n```json\n{\n  \"/people/:id\": {\n    \"GET\": {\n      \"name\": \"{{ faker 'name.fullName' }}\",\n      \"address\": \"{{ faker 'address.streetAddress'}}, {{ faker 'address.city' }}\"\n    }\n  }\n}\n```\n","readmeFilename":"README.md","homepage":"https://github.com/AmitWolfus/copycat#readme","repository":{"type":"git","url":"git+https://github.com/AmitWolfus/copycat.git"},"bugs":{"url":"https://github.com/AmitWolfus/copycat/issues"}}