A CLI tool to create and manage mock API endpoints. It is designed mainly for frontend developers who want a simple way to test their application without setting up a backend server.
- Initialize project with a
testapi.jsonfile. - Add new endpoints with
--method,--path,--responseand--status(status code is optional). - The new endpoints are stored in
testapi.jsonfile. Duplicate entries are prevented. - Start a local server in your desired port.
- Call the added endpoints and get its response.
npm i testapi-clitestapi-cli helptestapi-cli init #creates testapi.json filetestapi-cli add --method GET --path /users --response '[{"id":123,"name":"virat"},{"id":456,"name":"kohli"}]' --status 200- --method must be a valid HTTP method.
- --path must begin with '/'.
- --response must be valid JSON enclosed within single quotes.
- --status is optional (default: 200)
testapi-cli start --port 3000- --port must be in the range 1024-65535
GET http://localhost:3000/users[
{"id":123,"name":"virat"},
{"id":456,"name":"kohli"}
]- Implement delay option for responses.
- Add
listandremovecommands.