# mock-server **Repository Path**: logic5/mock-server ## Basic Information - **Project Name**: mock-server - **Description**: 我的mock数据 - **Primary Language**: Unknown - **License**: Not specified - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2025-06-02 - **Last Updated**: 2025-06-02 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # Mock Server A flexible mock server that supports multiple projects and automatically loads API configurations. ## Features - Supports multiple projects in different folders - Automatic API configuration loading - Hot reloading of mock configurations - Docker support with volume mounting - Node.js 20.9.0 support - PNPM package management ## Prerequisites - Node.js 20.9.0 - PNPM - Docker (optional) ## Installation 1. Install dependencies: ```bash pnpm install ``` ## Running the Server ### Using PNPM 1. Start the server: ```bash pnpm start ``` 2. For development with auto-reload: ```bash pnpm dev ``` ### Using Docker 1. Build the Docker image: ```bash docker build -t mock-server . ``` 2. Run the container: ```bash docker run -p 3000:3000 -v /path/to/your/mocks:/app/mocks mock-server ``` ## Configuration The server will automatically load all JSON files from the `mocks` directory. Each JSON file represents an API endpoint. ### Directory Structure ``` mocks/ ├── project1/ │ ├── endpoint1.json │ └── endpoint2.json └── project2/ └── endpoint3.json ``` ### Environment Variables - `PORT`: Server port (default: 3000) - `MOCK_DIR`: Custom mocks directory path (default: ./mocks) ## Example The server includes an example mock for the `/oil_tank_state` endpoint in the `yewei` project. To test it: ```bash curl http://localhost:3000/oil_tank_state ```