Skip to content

An express routing middleware for easily build up a mock restful API server.

Notifications You must be signed in to change notification settings

Ginioo/express-mock-server-router

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

38 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Express Mock Server Router

This is an express routing middleware for easily build up a mock restful API server.

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}`);
});

About

An express routing middleware for easily build up a mock restful API server.

Topics

Resources

Stars

Watchers

Forks

Packages

No packages published