Skip to content

Simple HTTP server with posibility to mock API and automatic reload routes on change route file

Notifications You must be signed in to change notification settings

marlic7/simple-mock-http-server

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Simple HTTP server with posibility to mock API (http and socket.io) and automatic reload routes on change route file

Install

# globally
npm install -g simple-mock-http-server
# or in project as dev dependencies
npm install --save-dev simple-mock-http-server

Usage

From hand

simple-mock-http-server -o -p 8080 -r mock-routes

With NPM scripts

package.json
...
"scripts": {
    "start": "./node_modules/.bin/simple-mock-http-server -o -p 8080 -r mock-routes",
}
...
npm run start
# or shorter (becouse of lifecycle script)
npm start

Route files

Route files spec are the same as in Express lib see: http://expressjs.com/en/guide/routing.html)

./mock-routes/routes_1.js
module.exports = (app) => {
    app.get('/users', (req, res) => {
        res.json({
            success: true,
            data: ['user1', 'user2', 'user3']
        });
    });
};

Help

simple-mock-http-server -h

About

Simple HTTP server with posibility to mock API and automatic reload routes on change route file

Resources

Stars

Watchers

Forks

Packages

No packages published