-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This PR adds the V2 functions API to the exports of `@netlify/functions`. --------- Co-authored-by: Eduardo Bouças <mail@eduardoboucas.com>
- Loading branch information
1 parent
3481b22
commit 894fb91
Showing
9 changed files
with
41 additions
and
21 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,26 @@ | ||
import type { Context } from './context.js' | ||
import type { Event } from './event.js' | ||
import type { Response, BuilderResponse, StreamingResponse } from './response.js' | ||
import type { HandlerContext } from './handler_context.js' | ||
import type { HandlerEvent } from './handler_event.js' | ||
import type { HandlerResponse, BuilderResponse, StreamingResponse } from './handler_response.js' | ||
|
||
export interface HandlerCallback<ResponseType extends Response = Response> { | ||
export interface HandlerCallback<ResponseType extends HandlerResponse = HandlerResponse> { | ||
// eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
(error: any, response: ResponseType): void | ||
} | ||
|
||
export interface BaseHandler<ResponseType extends Response = Response, C extends Context = Context> { | ||
(event: Event, context: C, callback?: HandlerCallback<ResponseType>): void | Promise<ResponseType> | ||
export interface BaseHandler< | ||
ResponseType extends HandlerResponse = HandlerResponse, | ||
C extends HandlerContext = HandlerContext, | ||
> { | ||
(event: HandlerEvent, context: C, callback?: HandlerCallback<ResponseType>): void | Promise<ResponseType> | ||
} | ||
|
||
export interface BackgroundHandler<C extends Context = Context> { | ||
(event: Event, context: C): void | Promise<void> | ||
export interface BackgroundHandler<C extends HandlerContext = HandlerContext> { | ||
(event: HandlerEvent, context: C): void | Promise<void> | ||
} | ||
|
||
export type Handler = BaseHandler<Response, Context> | ||
export type BuilderHandler = BaseHandler<BuilderResponse, Context> | ||
export type Handler = BaseHandler<HandlerResponse, HandlerContext> | ||
export type BuilderHandler = BaseHandler<BuilderResponse, HandlerContext> | ||
|
||
export interface StreamingHandler { | ||
(event: Event, context: Context): Promise<StreamingResponse> | ||
(event: HandlerEvent, context: HandlerContext): Promise<StreamingResponse> | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
export { Context as HandlerContext } from './context.js' | ||
export { Event as HandlerEvent } from './event.js' | ||
export { HandlerContext } from './handler_context.js' | ||
export { HandlerEvent } from './handler_event.js' | ||
export { BuilderHandler, Handler, BackgroundHandler, HandlerCallback, StreamingHandler } from './handler.js' | ||
export { BuilderResponse, Response as HandlerResponse, StreamingResponse } from './response.js' | ||
export { BuilderResponse, HandlerResponse, StreamingResponse } from './handler_response.js' | ||
export { Context } from './v2.js' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export type { Context } from '@netlify/serverless-functions-api' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters