Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@tinyhttp/app

Package Overview
Dependencies
Maintainers
1
Versions
305
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@tinyhttp/app - npm Package Compare versions

Comparing version 2.0.11 to 2.0.12

60

dist/index.js

@@ -226,9 +226,8 @@ import { STATUS_CODES, createServer } from 'http';

const fns = args.slice(1).flat();
if (base instanceof App) {
// Set App parent to current App
base.parent = this;
// Mount on root
base.mountpath = '/';
this.apps['/'] = base;
if (typeof base === 'function' || base instanceof App) {
fns.unshift(base);
}
else if (Array.isArray(base)) {
fns.unshift(...base);
}
const path = typeof base === 'string' ? base : '/';

@@ -244,36 +243,25 @@ let regex;

}
if (base === '/') {
for (const fn of fns)
super.use(base, mount(fn));
}
else if (typeof base === 'function' || base instanceof App) {
super.use('/', [base, ...fns].map(mount));
}
else if (Array.isArray(base)) {
super.use('/', [...base, ...fns].map(mount));
}
else {
const handlerPaths = [];
const handlerFunctions = [];
for (const fn of fns) {
if (fn instanceof App && ((_a = fn.middleware) === null || _a === void 0 ? void 0 : _a.length)) {
for (const mw of fn.middleware) {
handlerPaths.push(lead(base) + lead(mw.path));
handlerFunctions.push(fn);
}
}
else {
handlerPaths.push('');
const handlerPaths = [];
const handlerFunctions = [];
const handlerPathBase = path === '/' ? '' : lead(path);
for (const fn of fns) {
if (fn instanceof App && ((_a = fn.middleware) === null || _a === void 0 ? void 0 : _a.length)) {
for (const mw of fn.middleware) {
handlerPaths.push(handlerPathBase + lead(mw.path));
handlerFunctions.push(fn);
}
}
pushMiddleware(this.middleware)({
path: base,
regex,
type: 'mw',
handler: mount(handlerFunctions[0]),
handlers: handlerFunctions.slice(1).map(mount),
fullPaths: handlerPaths
});
else {
handlerPaths.push('');
handlerFunctions.push(fn);
}
}
pushMiddleware(this.middleware)({
path,
regex,
type: 'mw',
handler: mount(handlerFunctions[0]),
handlers: handlerFunctions.slice(1).map(mount),
fullPaths: handlerPaths
});
return this;

@@ -280,0 +268,0 @@ }

4

package.json
{
"name": "@tinyhttp/app",
"version": "2.0.11",
"version": "2.0.12",
"description": "0-legacy, tiny & fast web framework as a replacement of Express",

@@ -39,3 +39,3 @@ "type": "module",

"@tinyhttp/res": "2.0.9",
"@tinyhttp/router": "2.0.3",
"@tinyhttp/router": "2.0.4",
"header-range-parser": "^1.1.1",

@@ -42,0 +42,0 @@ "regexparam": "^2.0.0"

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