mini-web-server

1.0.2 • Public • Published

Mini web server

A small, dependency free, single route web server

  • Supports POST bodies
  • JSON by default (we'll encode responses for you)
  • ES8
  • No callbacks - routes return an object with 'status' and 'body'

Usage

    const webserver = require('mini-web-server'),
        STATUS_CODES = require('http-status-codes')
        port = 6666,
        host = 'localhost'
 
    await webserver(port, host, async function route(request) {
        log(`We have recieved a request!`)
        return {
            status: STATUS_CODES.OK,
            body: {
                'success': 'woo!'
            }
        }
    })
    log(`Started test web server to get response`)

Package Sidebar

Install

npm i mini-web-server

Weekly Downloads

1

Version

1.0.2

License

MIT

Unpacked Size

3.19 kB

Total Files

3

Last publish

Collaborators

  • mikemaccana