clear-router 2.1.12 → 2.2.0

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.
@@ -1,138 +0,0 @@
1
- import { H3, H3Event, Middleware as Middleware$1, TypedServerRequest } from "h3";
2
- import { NextFunction, Request, Response as Response$1 } from "express";
3
-
4
- //#region types/h3.d.ts
5
- type H3App = Omit<H3['fetch'], 'fetch'> & {
6
- fetch: (request: TypedServerRequest) => Promise<Response>;
7
- };
8
- type HttpRequest = H3Event['req'] & {
9
- getBody: () => Record<string, any>;
10
- };
11
- /**
12
- * HTTP context passed to route handlers
13
- */
14
- type HttpContext$1 = Omit<H3Event, 'req'> & {
15
- req: HttpRequest;
16
- };
17
- /**
18
- * Route handler function type
19
- */
20
- type RouteHandler$1 = (
21
- /**
22
- * H3 event context
23
- */
24
-
25
- ctx: HttpContext$1,
26
- /**
27
- * ClearRequest instance
28
- */
29
-
30
- req: ClearRequest) => any | Promise<any>;
31
- /**
32
- * Handler can be either a function or controller reference
33
- */
34
- type Handler$1 = RouteHandler$1 | ControllerHandler;
35
- //#endregion
36
- //#region src/Route.d.ts
37
- declare class Route<X = any, M = Middleware$1 | Middleware> {
38
- ctx: X;
39
- body: RequestData;
40
- query: RequestData;
41
- params: RequestData;
42
- clearRequest: ClearRequest;
43
- methods: HttpMethod[];
44
- path: string;
45
- handler: Handler$1;
46
- middlewares: M[];
47
- controllerName?: string;
48
- actionName?: string;
49
- handlerType: 'function' | 'controller';
50
- middlewareCount: number;
51
- constructor(methods: HttpMethod[], path: string, handler: Handler$1, middlewares?: M[]);
52
- }
53
- //#endregion
54
- //#region src/ClearRequest.d.ts
55
- declare class ClearRequest<X = any, M = Middleware$1 | Middleware> {
56
- [key: string]: any;
57
- /**
58
- * @param body - Parsed request body
59
- */
60
- body: RequestData;
61
- /**
62
- * @param query - Parsed query parameters
63
- */
64
- query: RequestData;
65
- /**
66
- * @param params - Parsed route parameters
67
- */
68
- params: RequestData;
69
- route: Route<X, M>;
70
- constructor(init?: Partial<ClearRequest>);
71
- }
72
- //#endregion
73
- //#region types/express.d.ts
74
- interface RequestWithGetBody extends Request {
75
- getBody: () => Record<string, any>;
76
- }
77
- /**
78
- * HTTP context passed to route handlers
79
- */
80
- interface HttpContext {
81
- req: RequestWithGetBody;
82
- res: Response$1;
83
- next: NextFunction;
84
- }
85
- /**
86
- * Route handler function type
87
- */
88
- type RouteHandler = (
89
- /**
90
- * Express context object containing req, res, and next
91
- */
92
-
93
- ctx: HttpContext,
94
- /**
95
- * ClearRequest instance
96
- */
97
-
98
- req: ClearRequest) => any | Promise<any>;
99
- /**
100
- * Handler can be either a function or controller reference
101
- */
102
- type Handler = RouteHandler | ControllerHandler;
103
- /**
104
- * Middleware function type
105
- */
106
- type Middleware = (req: Request, res: Response$1, next: NextFunction) => any | Promise<any>;
107
- //#endregion
108
- //#region types/basic.d.ts
109
- /**
110
- * Controller method reference
111
- */
112
- type ControllerHandler = [any, string];
113
- /**
114
- * HTTP methods supported by the router
115
- */
116
- type HttpMethod = 'get' | 'post' | 'put' | 'delete' | 'patch' | 'options' | 'head';
117
- /**
118
- * Common controller action names
119
- */
120
- type ControllerAction = 'index' | 'show' | 'create' | 'update' | 'destroy';
121
- /**
122
- * Generic Object type for request data
123
- */
124
- type RequestData = Record<string, any>;
125
- type ApiResourceMiddleware<M extends Middleware | Middleware$1> = M | M[] | { [K in ControllerAction]?: M | M[] };
126
- interface RouterConfig {
127
- /**
128
- * Configuration for method override functionality, allowing clients to use a
129
- * specific header or body parameter to override the HTTP method.
130
- */
131
- methodOverride?: {
132
- /** Whether method override is enabled */enabled?: boolean; /** Keys in the request body to check for method override */
133
- bodyKeys?: string[] | string; /** Keys in the request headers to check for method override */
134
- headerKeys?: string[] | string;
135
- };
136
- }
137
- //#endregion
138
- export { Handler as a, Route as c, HttpContext$1 as d, Middleware$1 as f, RouterConfig as i, H3App as l, ControllerAction as n, HttpContext as o, HttpMethod as r, Middleware as s, ApiResourceMiddleware as t, Handler$1 as u };