mimicio v1.0.1
Mimicio
A simple CLI tool for running a mock API server based on a directory structure.
Installation
npm install -g mimicioDirectory Structure
The mock server uses a specific directory structure to determine the available services, methods, endpoints, and responses. Here's an example of how to set up your directories and files:
root
├── serviceName
│ ├── GET
│ │ ├── endpointName
│ │ │ ├── 200.json
│ │ │ └── 404.json
│ ├── POST
│ │ ├── endpointName
│ │ │ └── 200.jsonIn this example:
serviceNameis the name of the service.GETandPOSTare HTTP methods.endpointNameis the name of the endpoint.200.jsonand404.jsonare JSON files representing the response bodies for their respective status codes.
Usage
Navigate to the root directory containing your service directories, then run the mimicio command:
mimicioThe mock server will start on a random available port in the range 3000-3999. The console will display the port number.
You can then send HTTP requests to the server. For example, if the server is running on port 3000, you could send a GET request to the endpointName endpoint of the serviceName service like this:
curl http://localhost:3000/serviceName/endpointNameThe server will respond with the contents of the 200.json file in the GET/endpointName directory of the serviceName service. If the 200.json file does not exist, the server will respond with a 500 Internal Server Error.
License
This project is licensed under the MIT License.