New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details
Socket
Book a DemoSign in
Socket

@tinyhttp/app

Package Overview
Dependencies
Maintainers
2
Versions
315
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
3.0.5
to
3.0.6
+19
-28
dist/app.js

@@ -16,9 +16,7 @@ import { createServer } from 'node:http';

const mount = (fn) => (fn instanceof App ? fn.attach : fn);
const applyHandler = (h) => async (req, res, next) => {
const applyHandler = (h, req, res, next) => {
if (h[Symbol.toStringTag] === 'AsyncFunction')
return h(req, res, next).catch(next);
try {
if (h[Symbol.toStringTag] === 'AsyncFunction') {
await h(req, res, next);
}
else
h(req, res, next);
h(req, res, next);
}

@@ -88,4 +86,3 @@ catch (e) {

this.applyExtensions = options?.applyExtensions;
const boundHandler = this.handler.bind(this);
this.attach = (req, res, next) => setImmediate(boundHandler, req, res, next);
this.attach = this.handler.bind(this);
this.cache = {};

@@ -102,3 +99,3 @@ }

enabled(setting) {
return Boolean(this.settings[setting]);
return !!this.settings[setting];
}

@@ -123,5 +120,4 @@ disable(setting) {

locals = { ...locals, ...data };
if (opts.cache == null)
opts.cache = this.enabled('view cache');
if (opts.cache) {
// biome-ignore lint/suspicious/noAssignInExpressions: its faster this way
if ((opts.cache ??= this.enabled('view cache'))) {
view = this.cache[name];

@@ -223,5 +219,4 @@ }

const result = [];
const isHead = method === 'HEAD';
for (let i = 0; i < this.middleware.length; i++) {
const m = this.middleware[i];
for (let i = 0, middlewares = this.middleware, isHead = method === 'HEAD'; i < middlewares.length; i++) {
const m = middlewares[i];
// Regex is pre-compiled at registration time in pushMiddleware

@@ -261,3 +256,3 @@ if (!m.regex?.pattern.test(url)) {

req.baseUrl = '';
const handle = async (middleware, pathname) => {
const handle = (middleware, pathname) => {
const { path, handler, regex } = middleware;

@@ -285,14 +280,12 @@ let params;

}
if (!req.params)
req.params = {};
Object.assign(req.params, params);
// biome-ignore lint/suspicious/noAssignInExpressions: its faster this way
Object.assign((req.params ??= {}), params);
if (middleware.type === 'mw') {
req.url = lead(req.originalUrl.substring(prefix.length));
req.baseUrl = trail(req.originalUrl.substring(0, prefix.length));
req.url = lead(req.originalUrl.slice(prefix.length));
req.baseUrl = trail(req.originalUrl.slice(0, prefix.length));
}
if (!req.path)
req.path = pathname;
req.path ??= pathname;
if (this.settings?.enableReqRoute)
req.route = middleware;
await applyHandler(handler)(req, res, next);
return applyHandler(handler, req, res, next);
};

@@ -309,4 +302,3 @@ let idx = 0;

}
mw.push(...matched);
mw.push(HEAD_HANDLER_MW);
mw.push(...matched, HEAD_HANDLER_MW);
}

@@ -331,4 +323,3 @@ else if (this.parent == null) {

if (idx >= mw.length) {
if (parentNext != null)
parentNext();
parentNext?.();
return;

@@ -335,0 +326,0 @@ }

@@ -6,5 +6,4 @@ import type { IncomingHttpHeaders, IncomingMessage } from 'node:http';

import { type Trust } from '@tinyhttp/proxy-addr';
import type { URLParams } from '@tinyhttp/req';
import type { RangeParserOptions, RangeParserRanges, URLParams } from '@tinyhttp/req';
import type { Middleware } from '@tinyhttp/router';
import type { Options, Ranges } from 'header-range-parser';
import type { App } from './app.js';

@@ -46,3 +45,3 @@ export { getURLParams } from '@tinyhttp/req';

get: <HeaderName extends string>(header: HeaderName) => IncomingHttpHeaders[HeaderName];
range: (size: number, options?: Options) => -1 | -2 | -3 | Ranges | undefined;
range: (size: number, options?: RangeParserOptions) => -1 | -2 | -3 | RangeParserRanges | undefined;
accepts: (...types: string[]) => AcceptsReturns;

@@ -49,0 +48,0 @@ acceptsEncodings: (...encodings: string[]) => AcceptsReturns;

{
"name": "@tinyhttp/app",
"version": "3.0.5",
"version": "3.0.6",
"description": "0-legacy, tiny & fast web framework as a replacement of Express",

@@ -35,3 +35,2 @@ "type": "module",

"dependencies": {
"header-range-parser": "1.1.3",
"regexparam": "^2.0.2",

@@ -41,5 +40,5 @@ "@tinyhttp/accepts": "^2.3.0",

"@tinyhttp/proxy-addr": "3.0.1",
"@tinyhttp/req": "2.2.7",
"@tinyhttp/res": "2.2.9",
"@tinyhttp/router": "2.2.4"
"@tinyhttp/req": "2.2.8",
"@tinyhttp/res": "2.2.10",
"@tinyhttp/router": "2.2.5"
},

@@ -46,0 +45,0 @@ "scripts": {

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet