express-mock-server-router
v1.1.10
Published
An express routing middleware for easily build up a mock restful API server.
Downloads
12
Readme
Express Mock Server Router
This is an express routing middleware for easily build up a mock restful API server.
Demo
Install
npm
npm install express-mock-server-router
yarn
yarn add express-mock-server-router
Usage
import express from 'express';
import mockServerRouter from 'express-mock-server-router';
const app = express();
const port = 3000;
const mockAPIUrl = '/api/v1.mock';
// `data/` is a under your project root.
app.use(mockServerRouter({
routes: [
{ url: mockAPIUrl, path: 'data/' }
]
}));
app.get('/', (req, res) => {
res.send(`mock server is running on <a href="${mockAPIUrl}"}>${mockAPIUrl}</a>`);
});
app.listen(port, () => {
console.log(`mock server is running on port ${port}`);
});