@wxn0brp/falcon-frame 0.9.9 → 0.9.11
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/README.md +2 -1
- package/dist/body-utils.js +3 -3
- package/dist/chain.d.ts +9 -0
- package/dist/chain.js +65 -0
- package/dist/compress.js +3 -3
- package/dist/debug.js +3 -6
- package/dist/engine.js +24 -28
- package/dist/error-handlers.d.ts +21 -0
- package/dist/error-handlers.js +72 -0
- package/dist/helpers.d.ts +4 -1
- package/dist/helpers.js +68 -5
- package/dist/https.d.ts +6 -0
- package/dist/https.js +35 -0
- package/dist/index.d.ts +23 -14
- package/dist/index.js +55 -52
- package/dist/middleware.js +11 -1
- package/dist/req.js +37 -47
- package/dist/res.d.ts +0 -1
- package/dist/res.js +0 -2
- package/dist/router.d.ts +6 -2
- package/dist/router.js +16 -4
- package/dist/safe.d.ts +9 -0
- package/dist/safe.js +79 -0
- package/dist/static.js +51 -11
- package/dist/types.d.ts +13 -1
- package/dist/types.js +4 -0
- package/dist/valid.js +1 -1
- package/package.json +1 -1
package/dist/types.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ import { LoggerOptions } from "@wxn0brp/lucerna-log";
|
|
|
2
2
|
import FalconFrame from "./index.js";
|
|
3
3
|
import { FFResponse } from "./res.js";
|
|
4
4
|
import http from "http";
|
|
5
|
-
export type RouteHandler = (req: FFRequest, res: FFResponse, next: () => void) => void | any;
|
|
5
|
+
export type RouteHandler = (req: FFRequest, res: FFResponse, next: () => Promise<void>) => void | any;
|
|
6
6
|
export type FinalHandler = (req: FFRequest, res: FFResponse) => void | any;
|
|
7
7
|
export type ErrorHandler = (err: Error, req: FFRequest, res: FFResponse) => void | any;
|
|
8
8
|
export type Method = "get" | "post" | "put" | "delete" | "patch" | "all";
|
|
@@ -73,6 +73,10 @@ export declare class FFRequest extends http.IncomingMessage {
|
|
|
73
73
|
ip: string;
|
|
74
74
|
/** True when proxy headers were used to resolve `ip`. */
|
|
75
75
|
isProxied: boolean;
|
|
76
|
+
/** Request protocol, respects `x-forwarded-proto` from a trusted proxy. */
|
|
77
|
+
protocol: "http" | "https";
|
|
78
|
+
/** True when the request came over HTTPS, directly or via a trusted proxy. */
|
|
79
|
+
secure: boolean;
|
|
76
80
|
header: (name: string) => string;
|
|
77
81
|
valid: (schema: ValidationSchema, regexRules?: Record<string, RegExp | string>) => ValidationResult;
|
|
78
82
|
middleware: Middleware;
|
|
@@ -89,6 +93,7 @@ export interface Middleware {
|
|
|
89
93
|
use?: true;
|
|
90
94
|
router?: Middleware[];
|
|
91
95
|
customParser?: true;
|
|
96
|
+
api?: true;
|
|
92
97
|
}
|
|
93
98
|
export interface CookieOptions {
|
|
94
99
|
maxAge?: number;
|
|
@@ -115,6 +120,8 @@ export interface StaticServeOptions {
|
|
|
115
120
|
etag?: boolean;
|
|
116
121
|
errorIfDirNotFound?: boolean;
|
|
117
122
|
notRenderHtml?: boolean;
|
|
123
|
+
/** Allow serving dotfiles. `.well-known` is always allowed as the first segment. Defaults to false. */
|
|
124
|
+
dotfiles?: boolean;
|
|
118
125
|
}
|
|
119
126
|
export interface StaticFileOptions {
|
|
120
127
|
utf8?: boolean;
|
|
@@ -160,3 +167,8 @@ export type FFVars = {
|
|
|
160
167
|
layout: string;
|
|
161
168
|
};
|
|
162
169
|
export type CombinedVars<ExtraVars> = ExtraVars & FFVars;
|
|
170
|
+
export interface ListenTarget {
|
|
171
|
+
host?: string;
|
|
172
|
+
port: number;
|
|
173
|
+
}
|
|
174
|
+
export type ListenAddress = number | string | ListenTarget;
|
package/dist/types.js
CHANGED
|
@@ -12,6 +12,10 @@ export class FFRequest extends http.IncomingMessage {
|
|
|
12
12
|
ip;
|
|
13
13
|
/** True when proxy headers were used to resolve `ip`. */
|
|
14
14
|
isProxied;
|
|
15
|
+
/** Request protocol, respects `x-forwarded-proto` from a trusted proxy. */
|
|
16
|
+
protocol;
|
|
17
|
+
/** True when the request came over HTTPS, directly or via a trusted proxy. */
|
|
18
|
+
secure;
|
|
15
19
|
header;
|
|
16
20
|
valid;
|
|
17
21
|
middleware;
|
package/dist/valid.js
CHANGED
|
@@ -172,7 +172,7 @@ export function validateBody(schema, regexRules) {
|
|
|
172
172
|
return (req, res, next) => {
|
|
173
173
|
const validationResult = req.valid(schema, regexRules);
|
|
174
174
|
if (!validationResult.valid) {
|
|
175
|
-
const errorResponse = res.FF._400_formatter(validationResult.validErrors);
|
|
175
|
+
const errorResponse = res.FF.errorHandlers._400_formatter(validationResult.validErrors);
|
|
176
176
|
res.status(400).json(errorResponse);
|
|
177
177
|
return;
|
|
178
178
|
}
|