npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

pure-http

v4.0.2

Published

The simple web framework for Node.js with zero dependencies.

Downloads

17,247

Readme

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:

  • server: Allows to optionally override the HTTP server instance to be used.

    Default: undefined.

  • onError: A handler when an error is thrown (Deprecated: It has been removed from 3.0.0).

    Default: ((error, req, res) => res.send(error)).

  • onNotFound: A handler when no route definitions were matched (Deprecated: It has been removed from 3.0.0).

    Default: ((req, res) => res.send("Cannot " + req.method + " " + req.url)).

  • views: An object to configuration render function.

    Default: undefined.

    • dir: A directory for the application's views.

    • ext: The default engine extension to use when omitted.

    • engine: Registers the given template engine.

  • Router Options:

    • prefix: Allow append the path before each route.

      Default: undefined.

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.

  • Machine: Ubuntu-s-1vcpu-1gb-sgp1-01, x86-64, Ubuntu 18.04.5 LTS, Intel(R) Xeon(R) CPU E5-2650 v4 @ 2.20GHz, 16GB RAM.
  • Node: v12.18.4
  • Run: Tue, 16 Mar 2021 16:09:01

| 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 |

  • Machine: Ubuntu-s-1vcpu-1gb-sgp1-01, x86-64, Ubuntu 18.04.5 LTS, Intel(R) Xeon(R) CPU E5-2650 v4 @ 2.20GHz, 16GB RAM.
  • Node: v12.18.4
  • Run: Fri, 13 Nov 2020 21:07:21

| 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