@tedckh/create-mock-server
v1.0.0
Published
A CLI to quickly generate a mock server with Fastify.
Readme
@tedckh/create-mock-server
A simple CLI tool to instantly generate a mock API server with Fastify.
Usage
To use this tool, run the following command in your terminal:
npx @tedckh/create-mock-serverThe CLI will ask you a few questions:
- Project Name: The name of the directory for your new mock server.
- API Path: The API endpoint you want to mock (e.g.,
/users,/products/1). - HTTP Method: The HTTP method for your endpoint (
GET,POST, etc.). - Port: The port for the mock server to run on (defaults to
3001).
It will then generate a complete, runnable Fastify project for you.
Generated Project
After running the command, follow the instructions to get your mock server running:
# 1. Navigate into your new project
cd <your-project-name>
# 2. Add your mock response data
# Open the .json file inside the 'mocks' directory and add your data.
# 3. Install dependencies
npm install
# 4. Start the server
npm startYour mock server will now be running at http://localhost:<your-port>.
Local Development (Contributing)
If you want to work on this CLI tool itself, follow these steps:
- Clone the repository.
- Navigate into the directory:
cd create-mock-server-cli - Install dependencies:
npm install - Link the package:
This command makes your local version of the CLI globally available on your machine.
npm link - Test your command:
You can now run
create-mock-serverfrom any directory to test your local changes.
License
MIT
