Socket
Socket
Sign inDemoInstall

@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.0 to 2.0.1

18

dist/index.js

@@ -80,7 +80,7 @@ import { STATUS_CODES, createServer } from 'http';

req.get = getRequestHeader(req);
if (settings?.bindAppToReqRes) {
if (settings === null || settings === void 0 ? void 0 : settings.bindAppToReqRes) {
req.app = app;
res.app = app;
}
if (settings?.networkExtensions) {
if (settings === null || settings === void 0 ? void 0 : settings.networkExtensions) {
req.protocol = getProtocol(req);

@@ -171,6 +171,6 @@ req.secure = req.protocol === 'https';

this.engines = {};
this.onError = options?.onError || onErrorHandler;
this.noMatchHandler = options?.noMatchHandler || this.onError.bind(null, { code: 404 });
this.onError = (options === null || options === void 0 ? void 0 : options.onError) || onErrorHandler;
this.noMatchHandler = (options === null || options === void 0 ? void 0 : options.noMatchHandler) || this.onError.bind(null, { code: 404 });
this.settings = options.settings || { xPoweredBy: true };
this.applyExtensions = options?.applyExtensions;
this.applyExtensions = options === null || options === void 0 ? void 0 : options.applyExtensions;
this.attach = (req, res) => setImmediate(this.handler.bind(this, req, res, undefined), req, res);

@@ -225,2 +225,3 @@ }

use(...args) {
var _a;
const base = args[0];

@@ -259,3 +260,3 @@ const fns = args.slice(1).flat();

for (const fn of fns) {
if (fn instanceof App && fn.middleware?.length) {
if (fn instanceof App && ((_a = fn.middleware) === null || _a === void 0 ? void 0 : _a.length)) {
for (const mw of fn.middleware) {

@@ -345,2 +346,3 @@ handlerPaths.push(lead(base) + lead(mw.path));

const handle = (mw) => async (req, res, next) => {
var _a;
const { path, handler, type, regex } = mw;

@@ -352,3 +354,3 @@ const params = regex ? getURLParams(regex, pathname) : {};

const first = Object.values(params)[0];
const url = req.url.slice(req.url.indexOf(first) + first?.length);
const url = req.url.slice(req.url.indexOf(first) + (first === null || first === void 0 ? void 0 : first.length));
req.url = lead(url);

@@ -361,3 +363,3 @@ }

req.path = getPathname(req.url);
if (this.settings?.enableReqRoute)
if ((_a = this.settings) === null || _a === void 0 ? void 0 : _a.enableReqRoute)
req.route = getRouteFromApp(this, handler);

@@ -364,0 +366,0 @@ await applyHandler(handler)(req, res, next);

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

@@ -35,7 +35,7 @@ "type": "module",

"dependencies": {
"@tinyhttp/cookie": "2.0.0",
"@tinyhttp/proxy-addr": "2.0.0",
"@tinyhttp/req": "2.0.0",
"@tinyhttp/res": "2.0.0",
"@tinyhttp/router": "2.0.0",
"@tinyhttp/cookie": "2.0.1",
"@tinyhttp/proxy-addr": "2.0.1",
"@tinyhttp/req": "2.0.1",
"@tinyhttp/res": "2.0.1",
"@tinyhttp/router": "2.0.1",
"regexparam": "^2.0.0"

@@ -42,0 +42,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