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 - npm Package Compare versions

Comparing version 0.0.9 to 0.0.12

20

lib/response.js

@@ -38,2 +38,12 @@ const { STATUS_CODES } = require('http');

if (cache) {
const bodyCached = cache.get(req.originUrl);
if (JSON.stringify(bodyCached) === JSON.stringify(body)) {
body = bodyCached;
} else {
cache.set(req.originUrl, body);
}
}
if (body && typeof body.pipe === 'function') {

@@ -57,12 +67,2 @@ headers[TYPE] = type || OCTET_STREAM;

if (cache) {
const bodyCached = cache.get(req.originUrl);
if (JSON.stringify(bodyCached) === JSON.stringify(body)) {
body = bodyCached;
} else {
cache.set(req.originUrl, body);
}
}
headers[TYPE] = type || TEXT_PLAIN;

@@ -69,0 +69,0 @@

@@ -51,2 +51,8 @@ const { regexToParams } = require('./utils');

function assertMiddleware(handler) {
if (typeof handler !== 'function' && !(handler instanceof Router)) {
throw new Error('Middleware must be a function!');
}
}
for (let i = hasPath ? 1 : 0; i < args.length; i += 1) {

@@ -59,5 +65,9 @@ const tmp = args[i];

assertMiddleware(t);
handlers.push(t);
}
} else {
assertMiddleware(tmp);
handlers.push(tmp);

@@ -67,10 +77,2 @@ }

for (let i = 0; i < handlers.length; i += 1) {
const handler = handlers[i];
if (typeof handler !== 'function' && !(handler instanceof Router)) {
throw new Error('Middleware must be a function!');
}
}
const { keys, pattern } = regexToParams(route, true);

@@ -84,3 +86,5 @@

const newRoutes = router.routes.map(({ path, fns, method }) => {
for (let j = 0; j < router.routes.length; j += 1) {
const { path, fns, method } = router.routes[j];
const { keys: newKey, pattern: newPattern } = regexToParams(

@@ -90,9 +94,3 @@ route + path,

return { keys: newKey, pattern: newPattern, fns, method };
});
for (let j = 0; j < newRoutes.length; j += 1) {
const r = newRoutes[j];
this.routes.push(r);
this.routes.push({ keys: newKey, pattern: newPattern, fns, method });
}

@@ -116,5 +114,3 @@ }

const sortableRoutes = this.routes.reverse();
sortableRoutes.sort((a, b) => {
this.routes.sort((a, b) => {
if (b.isMiddleware) return 0;

@@ -125,8 +121,8 @@

for (let i = 0; i < sortableRoutes.length; i += 1) {
const { keys, pattern, method, fns } = sortableRoutes[i];
for (let i = 0; i < this.routes.length; i += 1) {
const { keys, pattern, method, fns } = this.routes[i];
const { url } = req;
const methodNotAllowed = method.length !== 0 && method !== req.method;
let foundPath = false;

@@ -144,17 +140,5 @@ if (!keys) {

}
}
if (methodNotAllowed) {
const e = new Error('Method Not Allowed.');
e.statusCode = 405;
return callback(e);
foundPath = true;
}
if (fns.length > 1) {
handlers = handlers.concat(fns);
} else {
handlers.push(fns[0]);
}
} else if (keys.length > 0) {

@@ -167,18 +151,12 @@ matches = pattern.exec(url);

}
foundPath = true;
}
} else if (pattern.test(url)) {
foundPath = true;
}
if (methodNotAllowed) {
const e = new Error('Method Not Allowed.');
if (foundPath) {
const methodNotAllowed = method.length !== 0 && method !== req.method;
e.statusCode = 405;
return callback(e);
}
if (fns.length > 1) {
handlers = handlers.concat(fns);
} else {
handlers.push(fns[0]);
}
} else if (pattern.test(url)) {
if (methodNotAllowed) {

@@ -194,3 +172,3 @@ const e = new Error('Method Not Allowed.');

handlers = handlers.concat(fns);
} else {
} else if (fns[0]) {
handlers.push(fns[0]);

@@ -197,0 +175,0 @@ }

{
"name": "pure-http",
"version": "0.0.9",
"version": "0.0.12",
"description": "The simple web framework for Node.js with zero dependencies.",

@@ -42,4 +42,4 @@ "keywords": [

"commander": "^6.2.0",
"eslint": "^7.12.1",
"eslint-config-airbnb-base": "^14.2.0",
"eslint": "^7.13.0",
"eslint-config-airbnb-base": "^14.2.1",
"eslint-config-prettier": "^6.15.0",

@@ -46,0 +46,0 @@ "eslint-plugin-import": "^2.22.1",

@@ -97,5 +97,5 @@ <h1 align='center'>pure-http</h1>

- 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
- **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

@@ -102,0 +102,0 @@ | Framework | Version | Requests/Sec | Latency |

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