All Projects → htdangkhoa → Pure Http

htdangkhoa / Pure Http

Licence: mit
✨ The simple web framework for Node.js with zero dependencies.

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to Pure Http

Iris
The fastest HTTP/2 Go Web Framework. AWS Lambda, gRPC, MVC, Unique Router, Websockets, Sessions, Test suite, Dependency Injection and more. A true successor of expressjs and laravel | 谢谢 https://github.com/kataras/iris/issues/1329 |
Stars: ✭ 21,587 (+15430.22%)
Mutual labels:  middleware, framework, expressjs, server, router
Rayo.js
Micro framework for Node.js
Stars: ✭ 170 (+22.3%)
Mutual labels:  middleware, server, router, http-server, webserver
Restana
Super fast and minimalist framework for building REST micro-services.
Stars: ✭ 341 (+145.32%)
Mutual labels:  middleware, framework, http-server, webserver
Dragon
⚡A powerful HTTP router and URL matcher for building Deno web servers.
Stars: ✭ 56 (-59.71%)
Mutual labels:  middleware, framework, server, router
Golf
⛳️ The Golf web framework
Stars: ✭ 248 (+78.42%)
Mutual labels:  middleware, framework, server, router
Cppwebframework
​The C++ Web Framework (CWF) is a MVC web framework, Open Source, under MIT License, using C++ with Qt to be used in the development of web applications.
Stars: ✭ 348 (+150.36%)
Mutual labels:  framework, server, http-server, webserver
Twig
Twig - less is more's web server for golang
Stars: ✭ 98 (-29.5%)
Mutual labels:  middleware, framework, router, webserver
Diet
A tiny, fast and modular node.js web framework. Good for making fast & scalable apps and apis.
Stars: ✭ 394 (+183.45%)
Mutual labels:  api, middleware, router, http-server
Gin
Gin is a HTTP web framework written in Go (Golang). It features a Martini-like API with much better performance -- up to 40 times faster. If you need smashing performance, get yourself some Gin.
Stars: ✭ 53,971 (+38728.06%)
Mutual labels:  middleware, framework, server, router
Foxify
The fast, easy to use & typescript ready web framework for Node.js
Stars: ✭ 138 (-0.72%)
Mutual labels:  api, middleware, framework, router
Copper
Copper is a set of Go packages that help you build backend APIs quickly and with less boilerplate.
Stars: ✭ 35 (-74.82%)
Mutual labels:  api, middleware, router
Altair
Lightweight and Robust API Gateway written in Go
Stars: ✭ 34 (-75.54%)
Mutual labels:  api, middleware, router
Go Bootstrap
Easy way to bootstrap a web server in Go (Routing|Middleware|Https)
Stars: ✭ 27 (-80.58%)
Mutual labels:  middleware, server, http-server
Webcpp
用C++开发web服务器框架
Stars: ✭ 23 (-83.45%)
Mutual labels:  framework, http-server, webserver
Nodemcu Espress
Ultra-Lightweight and modular Node.js express like http server for NodeMCU. web - ESP8266
Stars: ✭ 39 (-71.94%)
Mutual labels:  api, server, http-server
Fortjs
Component based MVC web framework for nodejs targeting good code structures & modularity.
Stars: ✭ 44 (-68.35%)
Mutual labels:  framework, server, http-server
Chubbyphp Framework
A based PSR-15 microframework that also sets maximum flexibility with minimum complexity and easy replaceability of the individual components, but also of the framework.
Stars: ✭ 69 (-50.36%)
Mutual labels:  api, middleware, framework
Jennet
A simple HTTP web framework written in Pony
Stars: ✭ 72 (-48.2%)
Mutual labels:  router, http-server, webserver
Deno Drash
A REST microframework for Deno's HTTP server with zero 3rd party dependencies.
Stars: ✭ 795 (+471.94%)
Mutual labels:  api, framework, server
Flowa
🔥Service level control flow for Node.js
Stars: ✭ 66 (-52.52%)
Mutual labels:  api, expressjs, router

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

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

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 app = require('pure-http');

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

app.listen(3000);

API References

You can read more at API.md or this.

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

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].