@tinyhttp/app
Advanced tools
Comparing version 1.3.15 to 2.0.0
@@ -80,7 +80,7 @@ import { STATUS_CODES, createServer } from 'http'; | ||
req.get = getRequestHeader(req); | ||
if (settings === null || settings === void 0 ? void 0 : settings.bindAppToReqRes) { | ||
if (settings?.bindAppToReqRes) { | ||
req.app = app; | ||
res.app = app; | ||
} | ||
if (settings === null || settings === void 0 ? void 0 : settings.networkExtensions) { | ||
if (settings?.networkExtensions) { | ||
req.protocol = getProtocol(req); | ||
@@ -171,6 +171,6 @@ req.secure = req.protocol === 'https'; | ||
this.engines = {}; | ||
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.onError = options?.onError || onErrorHandler; | ||
this.noMatchHandler = options?.noMatchHandler || this.onError.bind(null, { code: 404 }); | ||
this.settings = options.settings || { xPoweredBy: true }; | ||
this.applyExtensions = options === null || options === void 0 ? void 0 : options.applyExtensions; | ||
this.applyExtensions = options?.applyExtensions; | ||
this.attach = (req, res) => setImmediate(this.handler.bind(this, req, res, undefined), req, res); | ||
@@ -225,3 +225,2 @@ } | ||
use(...args) { | ||
var _a; | ||
const base = args[0]; | ||
@@ -260,3 +259,3 @@ const fns = args.slice(1).flat(); | ||
for (const fn of fns) { | ||
if (fn instanceof App && ((_a = fn.middleware) === null || _a === void 0 ? void 0 : _a.length)) { | ||
if (fn instanceof App && fn.middleware?.length) { | ||
for (const mw of fn.middleware) { | ||
@@ -346,3 +345,2 @@ handlerPaths.push(lead(base) + lead(mw.path)); | ||
const handle = (mw) => async (req, res, next) => { | ||
var _a; | ||
const { path, handler, type, regex } = mw; | ||
@@ -354,3 +352,3 @@ const params = regex ? getURLParams(regex, pathname) : {}; | ||
const first = Object.values(params)[0]; | ||
const url = req.url.slice(req.url.indexOf(first) + (first === null || first === void 0 ? void 0 : first.length)); | ||
const url = req.url.slice(req.url.indexOf(first) + first?.length); | ||
req.url = lead(url); | ||
@@ -363,3 +361,3 @@ } | ||
req.path = getPathname(req.url); | ||
if ((_a = this.settings) === null || _a === void 0 ? void 0 : _a.enableReqRoute) | ||
if (this.settings?.enableReqRoute) | ||
req.route = getRouteFromApp(this, handler); | ||
@@ -366,0 +364,0 @@ await applyHandler(handler)(req, res, next); |
{ | ||
"name": "@tinyhttp/app", | ||
"version": "1.3.15", | ||
"version": "2.0.0", | ||
"description": "0-legacy, tiny & fast web framework as a replacement of Express", | ||
@@ -16,13 +16,4 @@ "type": "module", | ||
}, | ||
"main": "./dist/index.cjs", | ||
"types": "./dist/index.d.ts", | ||
"module": "./dist/index.js", | ||
"exports": { | ||
".": { | ||
"import": "./dist/index.js", | ||
"require": "./dist/index.cjs" | ||
}, | ||
"./package.json": "./package.json", | ||
"./": "./" | ||
}, | ||
"exports": "./dist/index.js", | ||
"files": [ | ||
@@ -45,7 +36,7 @@ "dist" | ||
"dependencies": { | ||
"@tinyhttp/cookie": "1.3.0", | ||
"@tinyhttp/proxy-addr": "1.3.0", | ||
"@tinyhttp/req": "1.3.1", | ||
"@tinyhttp/res": "1.3.3", | ||
"@tinyhttp/router": "1.3.3", | ||
"@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", | ||
"regexparam": "^2.0.0" | ||
@@ -56,2 +47,2 @@ }, | ||
} | ||
} | ||
} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
2
2
25958
10
605
+ Added@tinyhttp/accepts@2.0.0(transitive)
+ Added@tinyhttp/content-disposition@2.0.0(transitive)
+ Added@tinyhttp/cookie@2.0.0(transitive)
+ Added@tinyhttp/cookie-signature@2.0.0(transitive)
+ Added@tinyhttp/encode-url@2.0.0(transitive)
+ Added@tinyhttp/etag@2.0.0(transitive)
+ Added@tinyhttp/forwarded@2.0.0(transitive)
+ Added@tinyhttp/proxy-addr@2.0.0(transitive)
+ Added@tinyhttp/req@2.0.0(transitive)
+ Added@tinyhttp/res@2.0.0(transitive)
+ Added@tinyhttp/router@2.0.0(transitive)
+ Added@tinyhttp/send@2.0.0(transitive)
+ Added@tinyhttp/type-is@2.0.0(transitive)
+ Added@tinyhttp/url@2.0.0(transitive)
+ Addedes-content-type@0.1.0(transitive)
+ Addedes-escape-html@0.1.1(transitive)
+ Addedes-fresh@0.0.10(transitive)
+ Addedes-mime-types@0.1.4(transitive)
+ Addedes-vary@0.1.2(transitive)
- Removed@tinyhttp/accepts@1.3.0(transitive)
- Removed@tinyhttp/content-disposition@1.3.0(transitive)
- Removed@tinyhttp/cookie@1.3.0(transitive)
- Removed@tinyhttp/cookie-signature@1.3.0(transitive)
- Removed@tinyhttp/encode-url@0.3.0(transitive)
- Removed@tinyhttp/etag@1.3.0(transitive)
- Removed@tinyhttp/forwarded@1.3.0(transitive)
- Removed@tinyhttp/proxy-addr@1.3.0(transitive)
- Removed@tinyhttp/req@1.3.1(transitive)
- Removed@tinyhttp/res@1.3.3(transitive)
- Removed@tinyhttp/router@1.3.3(transitive)
- Removed@tinyhttp/send@1.3.2(transitive)
- Removed@tinyhttp/type-is@1.3.0(transitive)
- Removed@tinyhttp/url@1.3.1(transitive)
- Removedes-content-type@0.0.10(transitive)
- Removedes-fresh@0.0.8(transitive)
- Removedes-mime-types@0.0.16(transitive)
- Removedes-vary@0.0.8(transitive)
- Removedescape-html@1.0.3(transitive)
Updated@tinyhttp/cookie@2.0.0
Updated@tinyhttp/proxy-addr@2.0.0
Updated@tinyhttp/req@2.0.0
Updated@tinyhttp/res@2.0.0
Updated@tinyhttp/router@2.0.0