@tinyhttp/app 2.0.3 → 2.0.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/app.d.ts CHANGED
@@ -67,7 +67,7 @@ export declare class App<RenderOptions = any, Req extends Request = Request, Res
67
67
  * @param setting setting name
68
68
  * @param value setting value
69
69
  */
70
- set(setting: string, value: any): this;
70
+ set<T = unknown>(setting: string, value: T): this;
71
71
  /**
72
72
  * Enable app setting
73
73
  * @param setting Setting name
@@ -85,7 +85,7 @@ export declare class App<RenderOptions = any, Req extends Request = Request, Res
85
85
  * @param options Template engine options
86
86
  * @param cb Callback that consumes error and html
87
87
  */
88
- render(file: string, data: Record<string, any>, cb: (err: unknown, html: unknown) => void, options?: TemplateEngineOptions<RenderOptions>): this;
88
+ render(file: string, data: Record<string, unknown>, cb: (err: unknown, html: unknown) => void, options?: TemplateEngineOptions<RenderOptions>): this;
89
89
  use(...args: UseMethodParams<Req, Res, App>): this;
90
90
  /**
91
91
  * Register a template engine with extension
package/dist/index.js CHANGED
@@ -274,7 +274,7 @@ class App extends Router {
274
274
  fullPaths: handlerPaths
275
275
  });
276
276
  }
277
- return this; // chainable
277
+ return this;
278
278
  }
279
279
  /**
280
280
  * Register a template engine with extension
@@ -340,10 +340,9 @@ class App extends Router {
340
340
  });
341
341
  const handle = (mw) => async (req, res, next) => {
342
342
  var _a;
343
- const { path, handler, type, regex } = mw;
343
+ const { path, handler, regex } = mw;
344
344
  const params = regex ? getURLParams(regex, pathname) : {};
345
- if (type === 'route')
346
- req.params = params;
345
+ req.params = { ...req.params, ...params };
347
346
  if (path.includes(':')) {
348
347
  const first = Object.values(params)[0];
349
348
  const url = req.url.slice(req.url.indexOf(first) + (first === null || first === void 0 ? void 0 : first.length));
package/dist/request.d.ts CHANGED
@@ -1,13 +1,13 @@
1
1
  /// <reference types="node" />
2
2
  import { IncomingMessage } from 'http';
3
3
  import { ParsedUrlQuery } from 'querystring';
4
- import { Ranges } from 'range-parser';
4
+ import { Options, Ranges } from 'header-range-parser';
5
5
  import { App } from './app';
6
6
  import type { Middleware, Handler } from '@tinyhttp/router';
7
7
  import type { Response } from './response';
8
8
  import type { URLParams } from '@tinyhttp/req';
9
9
  export { getURLParams } from '@tinyhttp/req';
10
- export declare const getRouteFromApp: ({ middleware }: App, h: Handler<Request, Response>) => Middleware<Request, Response<any>>;
10
+ export declare const getRouteFromApp: ({ middleware }: App, h: Handler<Request, Response>) => Middleware<Request, Response>;
11
11
  export declare const getProtocol: (req: Request) => Protocol;
12
12
  export declare const getHostname: (req: Request) => string | undefined;
13
13
  export declare const getIP: (req: Pick<IncomingMessage, 'headers' | 'connection'>) => string | undefined;
@@ -35,7 +35,7 @@ export interface Request extends IncomingMessage {
35
35
  ips?: string[];
36
36
  subdomains?: string[];
37
37
  get: (header: string) => string | string[] | undefined;
38
- range: (size: number, options?: any) => -1 | -2 | Ranges | undefined;
38
+ range: (size: number, options?: Options) => -1 | -2 | -3 | Ranges | undefined;
39
39
  accepts: (...types: string[]) => AcceptsReturns;
40
40
  acceptsEncodings: (...encodings: string[]) => AcceptsReturns;
41
41
  acceptsCharsets: (...charsets: string[]) => AcceptsReturns;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tinyhttp/app",
3
- "version": "2.0.3",
3
+ "version": "2.0.9",
4
4
  "description": "0-legacy, tiny & fast web framework as a replacement of Express",
5
5
  "type": "module",
6
6
  "homepage": "https://tinyhttp.v1rtl.site",
@@ -32,11 +32,12 @@
32
32
  "author": "v1rtl",
33
33
  "license": "MIT",
34
34
  "dependencies": {
35
- "@tinyhttp/cookie": "2.0.1",
36
- "@tinyhttp/proxy-addr": "2.0.1",
37
- "@tinyhttp/req": "2.0.2",
38
- "@tinyhttp/res": "2.0.3",
39
- "@tinyhttp/router": "2.0.1",
35
+ "@tinyhttp/cookie": "2.0.3",
36
+ "@tinyhttp/proxy-addr": "2.0.2",
37
+ "@tinyhttp/req": "2.0.7",
38
+ "@tinyhttp/res": "2.0.8",
39
+ "@tinyhttp/router": "2.0.2",
40
+ "header-range-parser": "^1.0.0",
40
41
  "regexparam": "^2.0.0"
41
42
  },
42
43
  "scripts": {