pure-http

pure-http

Bring the middleware and router to native http.

depfu npm bundle size codefactor build coverage status eslint: airbnb code style: prettier

cover

Installation

$ npm install --save pure-http

Usage

Basic server:

const pureHttp = require('pure-http');

const app = pureHttp();

app.get('/', (req, res) => {
  res.send('Hello world');
});

app.listen(3000);

Existing server:

const http = require('http');
const pureHttp = require('pure-http');

const server = http.createServer();

const app = pureHttp({ server });

app.listen(3000);

Secure server:

const https = require('https');
const pureHttp = require('pure-http');

const server = https.createServer({
  key: ...,
  cert: ...,
});

const app = pureHttp({ server });

app.listen(3000);

Application Options:

Router

const { Router } = require('pure-http');

const router = Router();

router.get('/', (req, res) => {
  res.send('Hello world');
});

/* ... */

const pureHttp = require('pure-http');

const app = pureHttp();

app.use('/api', router);

app.listen(3000);

API References

You can read more at API.md.

Benchmarks

Please remember that your application code is most likely the slowest part of your application! Switching from Express to pure-http will (likely) not guarantee the same performance gains.

Framework Version Requests/Sec Latency
pure-http (with cache) latest ~ 6,349 15.11ms
pure-http latest ~ 6,255 15.39ms
tinyhttp 1.2.17 ~ 4,942 19.44ms
fastify 3.14.0 ~ 3,310 29.10ms
express 4.17.1 ~ 2,188 43.87ms
Framework Version Requests/Sec Latency
pure-http (with cache) 2.x.x ~ 8,792 10.92ms
pure-http 2.x.x ~ 8,633 11.12ms
polka 0.5.2 ~ 7,364 13.03ms
express 4.17.1 ~ 3,588 26.86ms
fastify 3.8.0 ~ 2,702 35.54ms

See more: BENCHMARKS

License

The code in this project is released under the MIT License.

FOSSA Status