|
| 1 | +# Mock Server |
| 2 | + |
| 3 | +<img src="./screenshot.png" alt="Mock Server" /> |
| 4 | + |
| 5 | +## Description |
| 6 | + |
| 7 | +Mock Server is a data mock server designed to facilitate UI and mobile development by providing a server to define endpoints and expected data. This allows developers to test and iterate on their applications without relying on actual backend services. |
| 8 | + |
| 9 | +## Getting Started |
| 10 | + |
| 11 | +Docker and Docker Compose installed on your machine- |
| 12 | + |
| 13 | +### Installation |
| 14 | + |
| 15 | +No installation is required, as the project uses Docker and Docker Compose. Simply clone the repository and navigate to the project directory. |
| 16 | + |
| 17 | +### Running the Project |
| 18 | + |
| 19 | +To run the Mock Server as a service: |
| 20 | + |
| 21 | +```bash |
| 22 | +docker run --name mock-server -p 8181:8000 -v your_config_file.yml:/app/config.yml webhkp/mock-server |
| 23 | +``` |
| 24 | + |
| 25 | + |
| 26 | +### Runnin for Developement |
| 27 | + |
| 28 | +For local development: |
| 29 | + |
| 30 | +```bash |
| 31 | +docker compose up |
| 32 | +``` |
| 33 | + |
| 34 | +This will start the Mock Server in development mode. |
| 35 | + |
| 36 | +### Setup configuration |
| 37 | + |
| 38 | +Directly edit ```config.yml``` and add configuration like below, under ```route```- |
| 39 | + |
| 40 | +```yaml |
| 41 | +- endpoint: customer |
| 42 | + methods: ["GET"] |
| 43 | + response: |
| 44 | + _id: 67ab90746a3103a3b60a3229 |
| 45 | + age: 32 |
| 46 | + balance: $3,953.98 |
| 47 | + eyeColor: brown |
| 48 | + gender: male |
| 49 | + guid: 320359a9-e3ad-45d7-bfbc-2f3966ac8805 |
| 50 | + index: 0 |
| 51 | + isActive: true |
| 52 | + name: Web Hkp |
| 53 | + status: 200 |
| 54 | +``` |
| 55 | +
|
| 56 | +Or open ```http://localhost:8181``` and you will see a form. You can enter your configuration in the form. |
| 57 | + |
| 58 | + |
| 59 | +## Features |
| 60 | + |
| 61 | +* Define endpoints and expected data for mocking backend services |
| 62 | +* Supports multiple endpoints and data formats |
| 63 | +* Easy to use and configure |
| 64 | + |
| 65 | +## Directory Layout |
| 66 | + |
| 67 | +* `app/`: Source code for the Mock Server |
| 68 | +* `docker-compose.yml`: Docker Compose configuration file |
| 69 | +* `Dockerfile`: Dockerfile for building the Mock Server image |
| 70 | +* `config.yml`: Configuration for api endpoint |
| 71 | + |
| 72 | +## Contributing |
| 73 | + |
| 74 | +Contributions are welcome! If you'd like to contribute to the project, please fork the repository and submit a pull request with your changes. |
| 75 | + |
| 76 | +## License |
| 77 | + |
| 78 | +This project is licensed under the [MIT License](https://opensource.org/licenses/MIT). |
| 79 | + |
| 80 | +## Technology Stack |
| 81 | + |
| 82 | +* Docker and Docker Compose for containerization and orchestration |
| 83 | +* Python and FastAPI framework for building the Mock Server |
0 commit comments