0.2.3 • Published 7 years ago

http-dev-server v0.2.3

Weekly downloads
3
License
MIT
Repository
github
Last release
7 years ago

http-dev-server

A simple http server for develop purpose, support rewrite request, mock response data and serve static resources.

##Install Install on global path

npm install -g http-dev-server   

Or install as a development dependency

npm install --save-dev http-dev-server   

##Usage Run server by global command

http-dev-server -f config-sample.js

Or config npm script and run server by npm (for example: {"server": "http-dev-server -f ./dev-server-config.js}")

npm run server

##Config Sample the content of config-sample.js

module.exports = {
    hostname: '0.0.0.0',
    port: '3000',
    webPath: __dirname,
    mockPath: __dirname,
    logLevel: 'debug',
    proxies: {
        '/api': {
            host: 'api.examples.com',
        },
        '/userapi': {
            host: '127.0.0.1:7000',
            headers: {
                host: 'api.examples.com'
            }
        }
    },
    mocks: {
        '/api/item/list': 'testdata/test.json',
        '/api/item/1': function(req, res) {
            res.json({ code: 0, data: { id: 1, name: "javascript in action" } });
        },
        '/api/cart': {
            'get': 'testdata/test.json',
            'post': function(req, res) {
                res.send("add cart successful");
            }
        }
    }
};

##Test Run project test using mocha

npm run test   

##Refs

0.2.3

7 years ago

0.2.2

8 years ago

0.2.1

8 years ago

0.2.0

8 years ago

0.1.3

8 years ago

0.1.2

8 years ago

0.1.1

8 years ago

0.1.0

8 years ago