Skip to content

Commit

Permalink
support async and sync function handlers (#28)
Browse files Browse the repository at this point in the history
  • Loading branch information
selfcontained authored Apr 18, 2022
1 parent c07892d commit 2d551dc
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion src/functions/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,22 @@ export type FunctionInvocationBody = {
};
};

export type FunctionHandler<InputParameters, OutputParameters> = {
type AsyncFunctionHandler<InputParameters, OutputParameters> = {
(
context: FunctionContext<InputParameters>,
): Promise<FunctionHandlerReturnArgs<OutputParameters>>;
};

type SyncFunctionHandler<InputParameters, OutputParameters> = {
(
context: FunctionContext<InputParameters>,
): FunctionHandlerReturnArgs<OutputParameters>;
};

export type FunctionHandler<InputParameters, OutputParameters> =
| AsyncFunctionHandler<InputParameters, OutputParameters>
| SyncFunctionHandler<InputParameters, OutputParameters>;

type SuccessfulFunctionReturnArgs<OutputParameters> = {
completed?: boolean;
outputs: OutputParameters;
Expand Down

0 comments on commit 2d551dc

Please sign in to comment.