Comparing version 1.1.0 to 1.2.0
@@ -0,5 +1,6 @@ | ||
const sequential = require('../lib/router/sequential') | ||
const cero = require('../index') | ||
const { router, server } = cero({ | ||
router: require('../lib/router/sequential')() | ||
router: sequential() | ||
}) | ||
@@ -6,0 +7,0 @@ |
@@ -0,5 +1,6 @@ | ||
const sequential = require('../lib/router/sequential') | ||
const cero = require('../index') | ||
const { router, server } = cero({ | ||
router: require('./../lib/router/sequential')() | ||
router: sequential() | ||
}) | ||
@@ -6,0 +7,0 @@ |
@@ -0,4 +1,6 @@ | ||
const sequential = require('../lib/router/sequential') | ||
const cero = require('../index') | ||
const { router, server } = cero({ | ||
router: require('./../lib/router/sequential')() | ||
router: sequential() | ||
}) | ||
@@ -5,0 +7,0 @@ |
@@ -7,3 +7,7 @@ const http = require('http') | ||
server.on('request', (req, res) => setImmediate(() => router.lookup(req, res))) | ||
server.on('request', (req, res) => { | ||
server instanceof http.Server | ||
? setImmediate(() => router.lookup(req, res)) | ||
: router.lookup(req, res) | ||
}) | ||
@@ -10,0 +14,0 @@ return { |
{ | ||
"name": "0http", | ||
"version": "1.1.0", | ||
"version": "1.2.0", | ||
"description": "Cero friction HTTP request router. The need for speed!", | ||
"main": "index.js", | ||
"scripts": { | ||
"test": "echo 'OK'" | ||
"lint": "npx standard", | ||
"format": "npx standard --fix", | ||
"test": "PORT=3000 NODE_ENV=testing npx nyc --check-coverage --lines 85 node ./node_modules/mocha/bin/mocha tests.js" | ||
}, | ||
@@ -26,3 +28,8 @@ "repository": { | ||
"devDependencies": { | ||
"standard": "^13.0.2" | ||
"chai": "^4.2.0", | ||
"mocha": "^6.2.0", | ||
"nyc": "^14.1.1", | ||
"standard": "^13.0.2", | ||
"supertest": "^4.0.2", | ||
"uWebSockets.js": "github:uNetworking/uWebSockets.js#v15.11.0" | ||
}, | ||
@@ -29,0 +36,0 @@ "dependencies": { |
@@ -82,7 +82,50 @@ # 0http | ||
``` | ||
## Servers | ||
`0http` is just a wrapper for the servers and routers implementations you provide. | ||
```js | ||
const cero = require('0http') | ||
## Benchmarks (21/07/2019) | ||
Node version: v10.16.0 | ||
Laptop: MacBook Pro 2016, 2,7 GHz Intel Core i7, 16 GB 2133 MHz LPDDR3 | ||
const { router, server } = cero({ | ||
server: yourCustomServerInstance | ||
}) | ||
``` | ||
### Node.js http.Server | ||
If no server is provided by configuration, the standard Node.js [http.Server](https://nodejs.org/api/http.html#http_class_http_server) implementation is used. | ||
Because this server offers the best balance between Node.js ecosystem compatibility and performance, we highly recommend it for most use cases. | ||
### Low Server | ||
`low` is a tiny Node.js friendly wrapper around the great [uWebSockets.js](https://github.com/uNetworking/uWebSockets.js) HTTP server. I/O throughput is | ||
maximized at the cost of API compatibility. | ||
> As far as for Node.js, `uWebSockets.js` brings the best I/O performance in terms of HTTP support. | ||
#### Install dependencies | ||
``` | ||
npm i uNetworking/uWebSockets.js#v15.11.0 | ||
``` | ||
#### Example usage | ||
```js | ||
const low = require('0http/lib/server/low') | ||
const cero = require('0http') | ||
const { router, server } = cero({ | ||
server: low() | ||
}) | ||
router.on('GET', '/hi', (req, res) => { | ||
res.end('Hello World!') | ||
}) | ||
server.listen(3000, (socket) => { | ||
if (socket) { | ||
console.log('HTTP server ready!') | ||
} | ||
}) | ||
``` | ||
## Benchmarks (22/07/2019) | ||
**Node version**: v10.16.0 | ||
**Laptop**: MacBook Pro 2016, 2,7 GHz Intel Core i7, 16 GB 2133 MHz LPDDR3 | ||
**Server**: Single instance | ||
```bash | ||
@@ -93,2 +136,4 @@ wrk -t8 -c8 -d5s http://127.0.0.1:3000/hi | ||
### 1 route registered | ||
- **0http (find-my-way + low)** | ||
`Requests/sec: 121006.70` | ||
- 0http (find-my-way) | ||
@@ -110,2 +155,2 @@ `Requests/sec: 680101.15` | ||
> For more accurate benchmarks please see: | ||
- https://github.com/the-benchmarker/web-frameworks | ||
> - https://github.com/the-benchmarker/web-frameworks |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
15844
19
363
153
6
2
2