@kravc/http

0.4.2 • Public • Published

@kravc/http

Minimal node.js HTTP server for web development.

API

Install:

npm i --save-dev @kravc/http

Get started

const { createServer } = require('@kravc/http')

await createServer(() => ({
  body:       JSON.stringify({ message: 'Hello, world!' }, null, 2),
  statusCode: 200
}))

Integration

In case you have module that exports request handler method, e.g ./index.js, add start script to package.json:

"scripts": {
  "start": "http"
}

Specify custom module name or port to start server on with options:

"scripts": {
  "start": "http ./module.js 4000"
}

Example of the npm start script with nodemon support:

"scripts": {
  "start": "NODE_PATH=./ nodemon -e js,yaml -w ./src --exec http"
}

Readme

Keywords

none

Package Sidebar

Install

npm i @kravc/http

Weekly Downloads

2

Version

0.4.2

License

ISC

Unpacked Size

5.29 kB

Total Files

7

Last publish

Collaborators

  • kravc