{"_id":"@afonso.oliveiragomes/api-mock-json","_rev":"1-17ca1d7a357ba5dd2f93cc6504150c0a","name":"@afonso.oliveiragomes/api-mock-json","dist-tags":{"latest":"1.0.1"},"versions":{"1.0.0":{"name":"@afonso.oliveiragomes/api-mock-json","version":"1.0.0","description":"This is a simple command-line tool for creating a mock API server based on a JSON configuration file. It uses [Express](https://expressjs.com/) to set up the server and allows you to define routes, HTTP methods, request parameters, request bodies, request","main":"index.js","scripts":{"test":"echo \"Error: no test specified\" && exit 1"},"bin":{"api-mock-json":"index.js"},"keywords":[],"author":"","license":"ISC","dependencies":{"@types/express":"^4.17.21","commander":"^11.1.0","cors":"^2.8.5","express":"^4.18.2"},"_id":"@afonso.oliveiragomes/api-mock-json@1.0.0","gitHead":"8f7bd0bfc17a18449344e08d784450d779f2ebe0","_nodeVersion":"20.11.0","_npmVersion":"10.2.4","dist":{"integrity":"sha512-6cm4yVGb9IxhLT0XbiSQLwtff3d2gXFve07i90Xpkb6zP/CVmgvgZ0KpIsV776EXwM12VLA5iAK1hvbD8pmq0g==","shasum":"2621ec35fea6abe50396ad7a0d41e6e016288c4e","tarball":"https://registry.npmjs.org/@afonso.oliveiragomes/api-mock-json/-/api-mock-json-1.0.0.tgz","fileCount":3,"unpackedSize":5792,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQD5eqUybzuT+Fjz/ZN+3c338GZjyth02gR1sTQZOuZaEwIhAJggwbSkmkl3jXiZuzNSuJowSyyhru7sDZvl3foNzEKf"}]},"_npmUser":{"name":"afonso.oliveiragomes","email":"afonso.oliveiragomes@gmail.com"},"directories":{},"maintainers":[{"name":"afonso.oliveiragomes","email":"afonso.oliveiragomes@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/api-mock-json_1.0.0_1706525222993_0.15292773265995896"},"_hasShrinkwrap":false},"1.0.1":{"name":"@afonso.oliveiragomes/api-mock-json","version":"1.0.1","type":"module","types":"index.ts","description":"This is a simple command-line tool for creating a mock API server based on a JSON configuration file. It uses [Express](https://expressjs.com/) to set up the server and allows you to define routes, HTTP methods, request parameters, request bodies, request","main":"index.js","scripts":{"test":"echo \"Error: no test specified\" && exit 1","build":"tsc --project ./"},"bin":{"api-mock-json":"index.js"},"keywords":[],"author":"","license":"ISC","dependencies":{"commander":"^11.1.0","cors":"^2.8.5","express":"^4.18.2"},"devDependencies":{"@types/commander":"^2.12.2","@types/cors":"^2.8.17","@types/express":"^4.17.21","tsc":"^2.0.4","typescript":"^5.3.3"},"_id":"@afonso.oliveiragomes/api-mock-json@1.0.1","gitHead":"65efd68ef330567be3eb44d060ce5815968617a6","_nodeVersion":"20.11.0","_npmVersion":"10.2.4","dist":{"integrity":"sha512-vQfFlrXulUOxiyIMBSbiFAE0IPGdvhlryQm6VrIBCilDoJ1Od/ORhYLXm/I2gas6+AJfmY4a6upgHC09eNswMQ==","shasum":"632111ae5875afc773da70d7b5443bf1cbfd68cf","tarball":"https://registry.npmjs.org/@afonso.oliveiragomes/api-mock-json/-/api-mock-json-1.0.1.tgz","fileCount":6,"unpackedSize":22807,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQDnrCoL8Q/fe9qi2PJYa2rPDYTuSsOJl0DrqqcpYC3e6AIgc3BkpgB+f+2bKOtjIv+lTcyEMHO/0a3RIkpOJxmw9Gw="}]},"_npmUser":{"name":"afonso.oliveiragomes","email":"afonso.oliveiragomes@gmail.com"},"directories":{},"maintainers":[{"name":"afonso.oliveiragomes","email":"afonso.oliveiragomes@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/api-mock-json_1.0.1_1706534000137_0.4291217058752905"},"_hasShrinkwrap":false}},"time":{"created":"2024-01-29T10:47:02.856Z","1.0.0":"2024-01-29T10:47:03.130Z","modified":"2024-01-29T13:13:20.449Z","1.0.1":"2024-01-29T13:13:20.286Z"},"maintainers":[{"name":"afonso.oliveiragomes","email":"afonso.oliveiragomes@gmail.com"}],"description":"This is a simple command-line tool for creating a mock API server based on a JSON configuration file. It uses [Express](https://expressjs.com/) to set up the server and allows you to define routes, HTTP methods, request parameters, request bodies, request","keywords":[],"license":"ISC","readme":"# API Mock JSON\n\nThis is a simple command-line tool for creating a mock API server based on a JSON configuration file. It uses [Express](https://expressjs.com/) to set up the server and allows you to define routes, HTTP methods, request parameters, request bodies, request headers, and response bodies through a JSON configuration file.\n\n## Installation\n\nEnsure you have [Node.js](https://nodejs.org/) installed on your machine.\n\n```bash\nnpm install -g @afonso.oliveiragomes/api-mock-json\n```\n\n## Usage\n\n```bash\napi-mock-json -r <path-to-routes-json> -p <port>\n```\n\n- **`-r, --routes`**: Path to the JSON file containing the route configurations.\n- **`-p, --port`**: Port number for the mock server. (Default is 9000)\n\n## JSON Configuration\n\nThe JSON file should contain an object where each key represents a route, and the corresponding value is an object specifying the configuration for that route.\n\nExample:\n\n```json\n{\n  \"/api/users\": {\n    \"method\": \"GET\",\n    \"response\": { \"users\": [] },\n    \"headers\": { \"Content-Type\": \"application/json\" }\n  },\n  \"/api/users/:id\": {\n    \"method\": \"GET\",\n    \"params\": { \"id\": \"1\" },\n    \"response\": { \"id\": 1, \"name\": \"John Doe\" }\n  },\n  \"/api/posts\": {\n    \"method\": \"POST\",\n    \"body\": { \"title\": \"Mock Post\", \"content\": \"This is a mock post.\" },\n    \"response\": { \"status\": \"success\", \"message\": \"Post created successfully.\" }\n  }\n}\n```\n\n- **`method`**: HTTP method for the route (GET, POST, PUT, PATCH, DELETE).\n- **`response`**: The response body for the route.\n- **`headers`**: (Optional) The expected request headers.\n- **`body`**: (Optional) The expected request body.\n- **`params`**: (Optional) The expected request parameters.\n\n## Example\n\n\n```bash\napi-mock-json -r mock-config.json -p 3000\n```\n\nThis command will start the mock server on http://localhost:3000 using the configurations specified in the mock-config.json file.\n\nVisit the specified routes on your browser or use tools like curl or Postman to make requests to the mock API.\n","readmeFilename":"README.md"}