UNPKG

next-safe-fetch

Version:

Type-safe server actions with middleware support

8 lines (7 loc) 503 B
export interface BaseMiddlewareContext { [key: string]: unknown; } export type MiddlewareFunction<TContext extends BaseMiddlewareContext> = () => Promise<TContext>; export type ActionResult<T> = Promise<T>; export type ActionFunctionWithInput<TInput, TOutput, TContext extends BaseMiddlewareContext> = (input: TInput, context: TContext) => ActionResult<TOutput>; export type ActionFunctionWithoutInput<TOutput, TContext extends BaseMiddlewareContext> = (context: TContext) => ActionResult<TOutput>;