![require(esm) Backported to Node.js 20, Paving the Way for ESM-Only Packages](https://cdn.sanity.io/images/cgdhsj6q/production/be8ab80c8efa5907bc341c6fefe9aa20d239d890-1600x1097.png?w=400&fit=max&auto=format)
Security News
require(esm) Backported to Node.js 20, Paving the Way for ESM-Only Packages
require(esm) backported to Node.js 20, easing the transition to ESM-only packages and reducing complexity for developers as Node 18 nears end-of-life.
Bring the middleware and router to native http.
$ npm install --save pure-http
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);
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))
.
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
.
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);
You can read more at API.md.
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.
v12.18.4
Framework | Version | Requests/Sec | Latency |
---|---|---|---|
pure-http (with cache) | latest | ~ 8,792 | 10.92ms |
pure-http | latest | ~ 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
The code in this project is released under the MIT License.
FAQs
The simple web framework for Node.js with zero dependencies.
The npm package pure-http receives a total of 2,299 weekly downloads. As such, pure-http popularity was classified as popular.
We found that pure-http demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
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.
Security News
require(esm) backported to Node.js 20, easing the transition to ESM-only packages and reducing complexity for developers as Node 18 nears end-of-life.
Security News
PyPI now supports iOS and Android wheels, making it easier for Python developers to distribute mobile packages.
Security News
Create React App is officially deprecated due to React 19 issues and lack of maintenance—developers should switch to Vite or other modern alternatives.