|
1 |
| -import type { Context } from './context.js' |
2 |
| -import type { Event } from './event.js' |
3 |
| -import type { Response, BuilderResponse, StreamingResponse } from './response.js' |
| 1 | +import type { HandlerContext } from './handler_context.js' |
| 2 | +import type { HandlerEvent } from './handler_event.js' |
| 3 | +import type { HandlerResponse, BuilderResponse, StreamingResponse } from './handler_response.js' |
4 | 4 |
|
5 |
| -export interface HandlerCallback<ResponseType extends Response = Response> { |
| 5 | +export interface HandlerCallback<ResponseType extends HandlerResponse = HandlerResponse> { |
6 | 6 | // eslint-disable-next-line @typescript-eslint/no-explicit-any
|
7 | 7 | (error: any, response: ResponseType): void
|
8 | 8 | }
|
9 | 9 |
|
10 |
| -export interface BaseHandler<ResponseType extends Response = Response, C extends Context = Context> { |
11 |
| - (event: Event, context: C, callback?: HandlerCallback<ResponseType>): void | Promise<ResponseType> |
| 10 | +export interface BaseHandler< |
| 11 | + ResponseType extends HandlerResponse = HandlerResponse, |
| 12 | + C extends HandlerContext = HandlerContext, |
| 13 | +> { |
| 14 | + (event: HandlerEvent, context: C, callback?: HandlerCallback<ResponseType>): void | Promise<ResponseType> |
12 | 15 | }
|
13 | 16 |
|
14 |
| -export interface BackgroundHandler<C extends Context = Context> { |
15 |
| - (event: Event, context: C): void | Promise<void> |
| 17 | +export interface BackgroundHandler<C extends HandlerContext = HandlerContext> { |
| 18 | + (event: HandlerEvent, context: C): void | Promise<void> |
16 | 19 | }
|
17 | 20 |
|
18 |
| -export type Handler = BaseHandler<Response, Context> |
19 |
| -export type BuilderHandler = BaseHandler<BuilderResponse, Context> |
| 21 | +export type Handler = BaseHandler<HandlerResponse, HandlerContext> |
| 22 | +export type BuilderHandler = BaseHandler<BuilderResponse, HandlerContext> |
20 | 23 |
|
21 | 24 | export interface StreamingHandler {
|
22 |
| - (event: Event, context: Context): Promise<StreamingResponse> |
| 25 | + (event: HandlerEvent, context: HandlerContext): Promise<StreamingResponse> |
23 | 26 | }
|
0 commit comments