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.34 to 2.1.0

2

dist/app.d.ts
/// <reference types="node/http.js" />
import { Server } from 'http';
import { Server } from 'node:http';
import type { Request } from './request.js';

@@ -4,0 +4,0 @@ import type { Response } from './response.js';

@@ -1,5 +0,19 @@

import { STATUS_CODES, createServer } from "http";
import path from "path";
var __accessCheck = (obj, member, msg) => {
if (!member.has(obj))
throw TypeError("Cannot " + msg);
};
var __privateAdd = (obj, member, value) => {
if (member.has(obj))
throw TypeError("Cannot add the same private member more than once");
member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
};
var __privateMethod = (obj, member, method) => {
__accessCheck(obj, member, "access private method");
return method;
};
var _find, find_fn;
import { STATUS_CODES, createServer } from "node:http";
import path from "node:path";
import { proxyaddr, all, compile } from "@tinyhttp/proxy-addr";
import { isIP } from "net";
import { isIP } from "node:net";
import { getRequestHeader, getQueryParams, getRangeFromHeader, getAccepts, getAcceptsCharsets, getAcceptsEncodings, getAcceptsLanguages, checkIfXMLHttpRequest, getFreshOrStale, getPathname, getURLParams } from "@tinyhttp/req";

@@ -24,3 +38,3 @@ import { getURLParams as getURLParams2 } from "@tinyhttp/req";

const getProtocol = (req) => {
const proto = req.connection.encrypted ? "https" : "http";
const proto = `http${req.connection.encrypted ? "s" : ""}`;
if (!trustRemoteAddress(req))

@@ -135,5 +149,6 @@ return proto;

};
class App extends Router {
const _App = class extends Router {
constructor(options = {}) {
super();
__privateAdd(this, _find);
this.middleware = [];

@@ -198,3 +213,3 @@ this.locals = {};

const fns = args.slice(1).flat();
if (typeof base === "function" || base instanceof App) {
if (typeof base === "function" || base instanceof _App) {
fns.unshift(base);

@@ -207,3 +222,3 @@ } else if (Array.isArray(base)) {

for (const fn of fns) {
if (fn instanceof App) {
if (fn instanceof _App) {
regex = parse(path2, true);

@@ -219,3 +234,3 @@ fn.mountpath = path2;

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

@@ -248,14 +263,6 @@ handlerPaths.push(handlerPathBase + lead(mw.path));

route(path2) {
const app = new App();
const app = new _App();
this.use(path2, app);
return app;
}
#find(url) {
return this.middleware.filter((m) => {
m.regex = m.regex || parse(m.path, m.type === "mw");
let fullPathRegex;
m.fullPath && typeof m.fullPath === "string" ? fullPathRegex = parse(m.fullPath, m.type === "mw") : fullPathRegex = null;
return m.regex.pattern.test(url) && (m.type === "mw" && fullPathRegex ? fullPathRegex.pattern.test(url) : true);
});
}
/**

@@ -273,3 +280,3 @@ * Extends Req / Res objects, pushes 404 and 500 handlers, dispatches middleware

const pathname = getPathname(req.originalUrl);
const matched = this.#find(pathname);
const matched = __privateMethod(this, _find, find_fn).call(this, pathname);
const mw = [

@@ -333,3 +340,13 @@ {

}
}
};
let App = _App;
_find = new WeakSet();
find_fn = function(url) {
return this.middleware.filter((m) => {
m.regex = m.regex || parse(m.path, m.type === "mw");
let fullPathRegex;
m.fullPath && typeof m.fullPath === "string" ? fullPathRegex = parse(m.fullPath, m.type === "mw") : fullPathRegex = null;
return m.regex.pattern.test(url) && (m.type === "mw" && fullPathRegex ? fullPathRegex.pattern.test(url) : true);
});
};
export {

@@ -336,0 +353,0 @@ App,

/// <reference types="node/http.js" />
import { IncomingMessage } from 'http';
import { ParsedUrlQuery } from 'querystring';
import { IncomingMessage } from 'node:http';
import type { ParsedUrlQuery } from 'node:querystring';
import { Options, Ranges } from 'header-range-parser';

@@ -9,4 +9,4 @@ import { App } from './app.js';

import type { URLParams } from '@tinyhttp/req';
import type { Socket } from 'net';
import type { TLSSocket } from 'tls';
import type { Socket } from 'node:net';
import type { TLSSocket } from 'node:tls';
export { getURLParams } from '@tinyhttp/req';

@@ -22,3 +22,3 @@ export declare const getRouteFromApp: ({ middleware }: App, h: Handler<Request, Response>) => Middleware<Request, Response>;

};
export type Protocol = 'http' | 'https' | string;
export type Protocol = 'node:http' | 'https' | string;
export type { URLParams };

@@ -25,0 +25,0 @@ type AcceptsReturns = string | boolean | string[];

/// <reference types="node/http.js" />
import { ServerResponse } from 'http';
import { ServerResponse } from 'node:http';
import type { SerializeOptions } from '@tinyhttp/cookie';

@@ -4,0 +4,0 @@ import { Request } from './request.js';

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

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

"regexparam": "^2.0.1",
"@tinyhttp/cookie": "2.0.7",
"@tinyhttp/proxy-addr": "2.0.8",
"@tinyhttp/req": "2.0.17",
"@tinyhttp/res": "2.0.24",
"@tinyhttp/router": "2.1.1"
"@tinyhttp/cookie": "2.1.0",
"@tinyhttp/proxy-addr": "2.1.0",
"@tinyhttp/req": "2.1.0",
"@tinyhttp/res": "2.1.0",
"@tinyhttp/router": "2.2.0"
},

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

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