@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/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
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wxn0brp/falcon-frame",
3
- "version": "0.9.9",
3
+ "version": "0.9.11",
4
4
  "main": "dist/index.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "author": "wxn0brP",