@tinyhttp/app 2.0.25 → 2.0.27
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/extend.d.ts +1 -1
- package/dist/index.js +8 -3
- package/dist/onError.d.ts +1 -1
- package/dist/response.d.ts +21 -21
- package/package.json +2 -2
package/dist/extend.d.ts
CHANGED
|
@@ -5,4 +5,4 @@ import { App } from './app.js';
|
|
|
5
5
|
/**
|
|
6
6
|
* Extends Request and Response objects with custom properties and methods
|
|
7
7
|
*/
|
|
8
|
-
export declare const extendMiddleware: <EngineOptions>(app: App) => (req: Request, res: Response<EngineOptions>, next: NextFunction) => void;
|
|
8
|
+
export declare const extendMiddleware: <EngineOptions>(app: App) => (req: Request, res: Response<EngineOptions, any>, next: NextFunction) => void;
|
package/dist/index.js
CHANGED
|
@@ -132,11 +132,16 @@ const applyHandler = (h) => async (req, res, next) => {
|
|
|
132
132
|
}
|
|
133
133
|
};
|
|
134
134
|
class App extends Router {
|
|
135
|
+
middleware = [];
|
|
136
|
+
locals = {};
|
|
137
|
+
noMatchHandler;
|
|
138
|
+
onError;
|
|
139
|
+
settings;
|
|
140
|
+
engines = {};
|
|
141
|
+
applyExtensions;
|
|
142
|
+
attach;
|
|
135
143
|
constructor(options = {}) {
|
|
136
144
|
super();
|
|
137
|
-
this.middleware = [];
|
|
138
|
-
this.locals = {};
|
|
139
|
-
this.engines = {};
|
|
140
145
|
this.onError = (options == null ? void 0 : options.onError) || onErrorHandler;
|
|
141
146
|
this.noMatchHandler = (options == null ? void 0 : options.noMatchHandler) || this.onError.bind(this, { code: 404 });
|
|
142
147
|
this.settings = options.settings || { xPoweredBy: true, views: process.cwd() };
|
package/dist/onError.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { NextFunction } from '@tinyhttp/router';
|
|
2
2
|
import type { Request } from './request.js';
|
|
3
3
|
import type { Response } from './response.js';
|
|
4
|
-
import type { App } from './app';
|
|
4
|
+
import type { App } from './app.js';
|
|
5
5
|
export declare type ErrorHandler = (this: App, err: any, req: Request, res: Response, next?: NextFunction) => void;
|
|
6
6
|
export declare const onErrorHandler: ErrorHandler;
|
package/dist/response.d.ts
CHANGED
|
@@ -11,30 +11,30 @@ export declare const renderTemplate: <O>(_req: Request, res: Response, app: App)
|
|
|
11
11
|
viewsFolder: string;
|
|
12
12
|
_locals: Record<string, any>;
|
|
13
13
|
}>) => Response;
|
|
14
|
-
export interface Response<O = any> extends ServerResponse {
|
|
15
|
-
header(field: string | Record<string, unknown>, val?: string | any[]): Response
|
|
16
|
-
set(field: string | Record<string, unknown>, val?: string | any[]): Response
|
|
14
|
+
export interface Response<O = any, B = any> extends ServerResponse {
|
|
15
|
+
header(field: string | Record<string, unknown>, val?: string | any[]): Response<O, B>;
|
|
16
|
+
set(field: string | Record<string, unknown>, val?: string | any[]): Response<O, B>;
|
|
17
17
|
get(field: string): string | number | string[];
|
|
18
|
-
send(body:
|
|
19
|
-
sendFile(path: string, options?: ReadStreamOptions, cb?: (err?: any) => void): Response
|
|
20
|
-
json(body:
|
|
21
|
-
status(status: number): Response
|
|
22
|
-
sendStatus(statusCode: number): Response
|
|
18
|
+
send(body: B): Response<O, B>;
|
|
19
|
+
sendFile(path: string, options?: ReadStreamOptions, cb?: (err?: any) => void): Response<O, B>;
|
|
20
|
+
json(body: B): Response<O, B>;
|
|
21
|
+
status(status: number): Response<O, B>;
|
|
22
|
+
sendStatus(statusCode: number): Response<O, B>;
|
|
23
23
|
cookie(name: string, value: string | Record<string, unknown>, options?: SerializeOptions & Partial<{
|
|
24
24
|
signed: boolean;
|
|
25
|
-
}>): Response
|
|
26
|
-
clearCookie(name: string, options?: SerializeOptions): Response
|
|
27
|
-
location(url: string): Response
|
|
25
|
+
}>): Response<O, B>;
|
|
26
|
+
clearCookie(name: string, options?: SerializeOptions): Response<O, B>;
|
|
27
|
+
location(url: string): Response<O, B>;
|
|
28
28
|
links(links: {
|
|
29
29
|
[key: string]: string;
|
|
30
|
-
}): Response
|
|
31
|
-
render(file: string, data?: Record<string, any>, options?: TemplateEngineOptions<O>): Response
|
|
32
|
-
vary(field: string): Response
|
|
33
|
-
format(obj: FormatProps): Response
|
|
34
|
-
redirect(url: string, status?: number): Response
|
|
35
|
-
type(type: string): Response
|
|
36
|
-
download(path: string, filename: string, options?: DownloadOptions, cb?: (err?: any) => void): Response
|
|
37
|
-
attachment(filename?: string): Response
|
|
30
|
+
}): Response<O, B>;
|
|
31
|
+
render(file: string, data?: Record<string, any>, options?: TemplateEngineOptions<O>): Response<O, B>;
|
|
32
|
+
vary(field: string): Response<O, B>;
|
|
33
|
+
format(obj: FormatProps): Response<O, B>;
|
|
34
|
+
redirect(url: string, status?: number): Response<O, B>;
|
|
35
|
+
type(type: string): Response<O, B>;
|
|
36
|
+
download(path: string, filename: string, options?: DownloadOptions, cb?: (err?: any) => void): Response<O, B>;
|
|
37
|
+
attachment(filename?: string): Response<O, B>;
|
|
38
38
|
app?: App;
|
|
39
39
|
locals?: Record<string, any>;
|
|
40
40
|
/**
|
|
@@ -44,6 +44,6 @@ export interface Response<O = any> extends ServerResponse {
|
|
|
44
44
|
*
|
|
45
45
|
* @param obj Response object
|
|
46
46
|
*/
|
|
47
|
-
jsonp(obj: any): Response
|
|
48
|
-
append(field: string, value: any): Response
|
|
47
|
+
jsonp(obj: any): Response<O, B>;
|
|
48
|
+
append(field: string, value: any): Response<O, B>;
|
|
49
49
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tinyhttp/app",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.27",
|
|
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",
|
|
@@ -35,7 +35,7 @@
|
|
|
35
35
|
"@tinyhttp/cookie": "2.0.5",
|
|
36
36
|
"@tinyhttp/proxy-addr": "2.0.5",
|
|
37
37
|
"@tinyhttp/req": "2.0.14",
|
|
38
|
-
"@tinyhttp/res": "2.0.
|
|
38
|
+
"@tinyhttp/res": "2.0.20",
|
|
39
39
|
"@tinyhttp/router": "2.0.6",
|
|
40
40
|
"header-range-parser": "1.1.3",
|
|
41
41
|
"regexparam": "^2.0.1"
|