New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

pure-http

Package Overview
Dependencies
Maintainers
1
Versions
39
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

pure-http

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

  • 0.0.12
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
664
decreased by-74.66%
Maintainers
1
Weekly downloads
 
Created
Source

pure-http

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

Exist 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);

Options

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

    Default: undefined.

  • onError: A handler when an error is thrown.

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

  • onNotFound: A handler when no route definitions were matched.

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

Router

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

const router = Router();

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

/* ... */

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

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

app.listen(3000);

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: Fri, 13 Nov 2020 21:07:21
FrameworkVersionRequests/SecLatency
pure-http (with cache)latest~ 8,79210.92ms
pure-httplatest~ 8,63311.12ms
polka0.5.2~ 7,36413.03ms
express4.17.1~ 3,58826.86ms
fastify3.8.0~ 2,70235.54ms

See more: BENCHMARKS

Keywords

FAQs

Package last updated on 15 Nov 2020

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc