en un clic
api-mock-server
Generate a mock API server from OpenAPI specs, TypeScript interfaces, or endpoint descriptions for frontend development and testing. Use when the user asks to create a mock server, fake API, or stub endpoints.
Menu
Generate a mock API server from OpenAPI specs, TypeScript interfaces, or endpoint descriptions for frontend development and testing. Use when the user asks to create a mock server, fake API, or stub endpoints.
Map and visualize module dependencies, detect circular imports, and identify coupling hotspots. Use when the user asks to analyze dependencies, find circular imports, or understand module relationships.
Generate typed error classes, error handling middleware, and HTTP error mapping following project conventions. Use when the user asks to set up error handling, create error classes, or implement error middleware.
Create, manage, and clean up feature flags for gradual rollouts and safe deployments. Use when the user asks to add a feature flag, toggle, or manage feature gating.
Generate docker-compose.yml files for local development with application services, databases, caches, and queues. Use when the user asks to set up a local dev environment or create docker-compose configuration.
Generate OpenSearch Dashboards (Kibana) saved objects — index patterns, visualizations, and dashboards as JSON. Use when the user asks to create dashboards, charts, or visualizations for OpenSearch/Elasticsearch/Kibana.
Design and create automation workflows — shell scripts, Cursor hooks, GitHub Actions, cron jobs, and task runners. Use when the user asks to automate a process, create a script, or set up a workflow.
| name | api-mock-server |
| description | Generate a mock API server from OpenAPI specs, TypeScript interfaces, or endpoint descriptions for frontend development and testing. Use when the user asks to create a mock server, fake API, or stub endpoints. |
Generate a lightweight mock API server that returns realistic responses for frontend development and integration testing.
When the user asks to mock an API, create a fake backend, stub endpoints, or generate a dev server from a spec.
| Approach | Tool | Best For |
|---|---|---|
| JSON Server | json-server | Quick REST mock from a JSON file |
| MSW (Mock Service Worker) | msw | Browser/Node request interception for tests |
| Express mock | express | Custom logic, delays, error simulation |
| Prism | @stoplight/prism-cli | Auto-mock from OpenAPI spec |
test-data-factory skill to create realistic data// mock-db.json
{
"users": [
{ "id": "usr_001", "name": "Alice Johnson", "email": "alice@example.com", "role": "admin" },
{ "id": "usr_002", "name": "Bob Smith", "email": "bob@example.com", "role": "user" }
],
"orders": [
{ "id": "ord_001", "userId": "usr_001", "status": "CONFIRMED", "total": 99.99 }
]
}
npx json-server mock-db.json --port 3001 --delay 200
// mocks/handlers.ts
import { http, HttpResponse } from 'msw';
export const handlers = [
http.get('/api/v1/users', () => {
return HttpResponse.json({
data: [
{ id: 'usr_001', name: 'Alice Johnson', email: 'alice@example.com' },
],
meta: { correlationId: 'mock-123', timestamp: new Date().toISOString() },
});
}),
http.post('/api/v1/users', async ({ request }) => {
const body = await request.json();
return HttpResponse.json(
{ data: { id: 'usr_new', ...body }, meta: { correlationId: 'mock-456' } },
{ status: 201 }
);
}),
http.get('/api/v1/users/:id', ({ params }) => {
if (params.id === 'not-found') {
return HttpResponse.json(
{ error: { code: 'NOT_FOUND', message: 'User not found' } },
{ status: 404 }
);
}
return HttpResponse.json({
data: { id: params.id, name: 'Alice Johnson' },
});
}),
];
// mocks/server.ts (Node.js)
import { setupServer } from 'msw/node';
import { handlers } from './handlers';
export const server = setupServer(...handlers);
// mocks/browser.ts (Browser)
import { setupWorker } from 'msw/browser';
import { handlers } from './handlers';
export const worker = setupWorker(...handlers);
// mock-server.ts
import express from 'express';
const app = express();
app.use(express.json());
// Simulate latency
app.use((req, res, next) => {
setTimeout(next, 100 + Math.random() * 200);
});
app.get('/api/v1/resources', (req, res) => {
const page = parseInt(req.query.cursor as string) || 0;
res.json({
data: generateResources(20),
meta: {
cursor: page + 20,
hasMore: page < 100,
correlationId: req.headers['x-correlation-id'] || 'mock',
},
});
});
// Error simulation
app.get('/api/v1/error', (req, res) => {
res.status(500).json({ error: { code: 'INTERNAL_ERROR', message: 'Simulated error' } });
});
app.listen(3001, () => console.log('Mock server on http://localhost:3001'));
{
"scripts": {
"mock": "npx json-server mock-db.json --port 3001",
"mock:msw": "ts-node mocks/server.ts"
}
}
@example.com emails, fake names, and UUID-style IDsWorking mock server with realistic data, error scenarios, and run instructions.
graphql handlers instead of httpws library for mock WebSocket server