Mockpit is a versatile and user-friendly REST API mock server that empowers developers to create and manage mock APIs effortlessly. With Mockpit, you can dynamically generate response bodies, leverage path variables and query parameters, and define custom response headers to simulate a wide range of API behaviors. Whether you're testing your frontend application, developing a new feature, or need a temporary API for your project, Mockpit has you covered.
- Dynamic Response Generation: Use JavaScript in ResponseBody evaluation to create dynamic response bodies based on path variables and query parameters.
- Path Variables and Query Parameters: Mockpit automatically extracts path variables and query parameters from the request URL and makes them available for dynamic response generation.
- Custom Response Headers: Configure response headers for your mock APIs, allowing you to simulate various scenarios.
- Mock Search: Quickly locate your mock configurations using Mockpit's search functionality. This feature ensures that you can easily find and work with the mocks you need.
- Export and Import Mocks: Seamlessly export and import mock configurations to and from Mockpit. Share your mock setups with colleagues and collaborators to ensure consistency across your team's development efforts.
- Easy-to-Use Configuration: Mockpit's intuitive user interface lets you create, edit, and manage mock APIs effortlessly.
- Fast and Lightweight: Mockpit is designed to be fast and lightweight, ensuring minimal impact on your development workflow.
- Java 11
- Maven
- Node 14.21
- Angular 15
- Postgres 15
-
Clone the Mockpit repository:
git clone https://github.com/sranmanpreet/mockpit.git
-
Install Server:
cd mockpit/server mvn clean install java -jar target/mockpit-<version>-RELEASE.jar
Server will be deployed on http://localhost:8080 by default. However, port can be changed from application configurations.
-
Install Client:
cd mockpit/client npm install npm start
Client will be deployed on http://localhost:4200 by default.
- Install Mockpit
docker run -e "SPRING_DATASOURCE_URL=jdbc:postgresql://host.docker.internal:5432/mockpitdb" -e "SPRING_DATASOURCE_USERNAME=postgres" -e "SPRING_DATASOURCE_PASSWORD=postgres" -e "backendUrl=http://localhost:8080" -p 4200:80 -p 8080:8080 sranmanpreet/mockpit:<version>-RELEASE
It will run Mockpit client at http://localhost:4200 and Mockpit server at http://localhost:8080.
Separate images for Mockpit client and server are also available. Follow below steps to install client and server individually.
- Install Server
docker run -e "SPRING_DATASOURCE_URL=jdbc:postgresql://host.docker.internal:5432/mockpitdb" -e "SPRING_DATASOURCE_USERNAME=postgres" -e "SPRING_DATASOURCE_PASSWORD=postgres" -p 8080:8080 mockpit-server:<version>-RELEASE
- Install Client
docker run -p 4200:80 -e backendUrl=http://localhost:8080 sranmanpreet/mockpit-server:<version>-RELEASE
Mockpit will be accessible at http://localhost:4200
- Run following command at the root of the project
docker-compose -f docker-compose.yml up -d
-
After installation with default configurations, access the Mockpit web interface by navigating to http://localhost:4200 in your web browser.
-
Create and manage mock APIs using the user-friendly interface. Configure dynamic response bodies, path variables, query parameters, and custom response headers as needed.
Here's a quick example of creating a mock API in Mockpit:
- Access the Mockpit web interface at http://localhost:4200.
- Click on "New Mock" to define a new mock API.
- Configure the URL pattern, dynamic response body using JavaScript, and custom response headers.
- Save the mock and start using it in your application.
- Manage mocks
Mockpit welcomes collaboration from developers like you! If you'd like to contribute to the project, feel free to open an issue, submit a pull request, or provide feedback.
To contribute:
- Fork the Mockpit repository.
- Create a new branch for your changes.
- Make your changes and test thoroughly.
- Submit a pull request with a clear description of your changes.
Mockpit is released under the MIT License.
Mockpit empowers you to easily create, manage, and test mock APIs with dynamic response generation and custom headers. Start using Mockpit today to streamline your development and testing workflows!