lambda-pipe 1.0.0 → 1.0.1
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/build/cli/dev.d.ts +1 -0
- package/build/cli/server.d.ts +1 -0
- package/build/cli/shared.d.ts +9 -9
- package/package.json +1 -1
package/build/cli/dev.d.ts
CHANGED
package/build/cli/server.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { RouteLoader, RuntimeMiddleware, RuntimePlugin } from './shared';
|
|
2
|
+
export type { RouteDefinition, RouteLoader, RuntimeContext, RuntimeMiddleware, RuntimePlugin, RuntimeResponse, } from './shared';
|
|
2
3
|
export type CreateRuntimeAppOptions = {
|
|
3
4
|
routes: RouteLoader[];
|
|
4
5
|
logger?: boolean;
|
package/build/cli/shared.d.ts
CHANGED
|
@@ -16,20 +16,20 @@ export type RuntimeResponse = {
|
|
|
16
16
|
headers?: Record<string, any>;
|
|
17
17
|
body?: any;
|
|
18
18
|
};
|
|
19
|
-
export type RuntimeMiddleware = (
|
|
19
|
+
export type RuntimeMiddleware = (context: RuntimeContext) => Promise<void> | void;
|
|
20
20
|
export type RuntimePlugin = {
|
|
21
21
|
name?: string;
|
|
22
22
|
onInit?: (app: any) => Promise<void> | void;
|
|
23
|
-
onRequest?: (
|
|
24
|
-
onResponse?: (
|
|
25
|
-
onError?: (error: unknown,
|
|
23
|
+
onRequest?: (context: RuntimeContext) => Promise<void> | void;
|
|
24
|
+
onResponse?: (context: RuntimeContext, response: RuntimeResponse) => Promise<void> | void;
|
|
25
|
+
onError?: (error: unknown, context: RuntimeContext) => Promise<void> | void;
|
|
26
26
|
};
|
|
27
27
|
export type RouteDefinition = {
|
|
28
28
|
__isRoute?: boolean;
|
|
29
29
|
path: string;
|
|
30
30
|
method: string;
|
|
31
31
|
middlewares?: RuntimeMiddleware[];
|
|
32
|
-
handler: (
|
|
32
|
+
handler: (context: RuntimeContext, app: any) => Promise<RuntimeResponse>;
|
|
33
33
|
};
|
|
34
34
|
export type RouteModule = {
|
|
35
35
|
default: RouteDefinition;
|
|
@@ -37,13 +37,13 @@ export type RouteModule = {
|
|
|
37
37
|
export type RouteLoader = () => Promise<RouteModule>;
|
|
38
38
|
export declare const moduleCache: WeakMap<RouteLoader, RouteDefinition>;
|
|
39
39
|
export declare function createRuntimeContext(req: FastifyRequest, reply: FastifyReply): RuntimeContext;
|
|
40
|
-
export declare function runMiddlewares(middlewares: RuntimeMiddleware[] | undefined,
|
|
40
|
+
export declare function runMiddlewares(middlewares: RuntimeMiddleware[] | undefined, context: RuntimeContext): Promise<void>;
|
|
41
41
|
export declare function serializeResponse(reply: FastifyReply, response: RuntimeResponse): Promise<any>;
|
|
42
|
-
export declare function handleRuntimeError(error: any,
|
|
42
|
+
export declare function handleRuntimeError(error: any, context: RuntimeContext, plugins?: RuntimePlugin[]): Promise<{
|
|
43
43
|
error: any;
|
|
44
44
|
stack: any;
|
|
45
45
|
}>;
|
|
46
46
|
export declare function loadRouteModule(load: RouteLoader): Promise<RouteDefinition>;
|
|
47
47
|
export declare function runPluginOnInit(plugins: RuntimePlugin[] | undefined, app: any): Promise<void>;
|
|
48
|
-
export declare function runPluginOnRequest(plugins: RuntimePlugin[] | undefined,
|
|
49
|
-
export declare function runPluginOnResponse(plugins: RuntimePlugin[] | undefined,
|
|
48
|
+
export declare function runPluginOnRequest(plugins: RuntimePlugin[] | undefined, context: RuntimeContext): Promise<void>;
|
|
49
|
+
export declare function runPluginOnResponse(plugins: RuntimePlugin[] | undefined, context: RuntimeContext, response: RuntimeResponse): Promise<void>;
|