sindresorhus / awesome-nodejs

:zap: Delightful Node.js packages and resources
https://node.cool
Creative Commons Zero v1.0 Universal
57.83k stars 5.81k forks source link

Add pure-http #1109

Closed htdangkhoa closed 1 year ago

htdangkhoa commented 3 years ago

By submitting this pull request, I promise I have read the contribution guidelines twice and ensured my submission follows it. I realize not doing so wastes the maintainers' time that they could have spent making the world better. 🖖

⬆⬆⬆⬆⬆⬆⬆⬆⬆⬆

pure-http is a simple web framework for Node.js with zero dependencies and low latency. That helps you use the middleware and router in native 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);

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);
sindresorhus commented 1 year ago

Thanks for the suggestion. I'm unfortunately going to pass on this one.