UNPKG

zod-server-actions

Version:

Simple utility library to create server actions in Next.js

8 lines (7 loc) 594 B
import { z, ZodTypeAny } from "zod"; import { CreateHandlerProps, HandlerFn } from "../types"; import { ActionResponse } from "./response"; type HandlerProps<T extends ZodTypeAny, C extends object, R> = CreateHandlerProps<HandlerFn<T, C, R>, C>; export type HandlerReturn<I extends ZodTypeAny, R> = (input: z.infer<I>) => Promise<ActionResponse<R>>; export declare const createAction: <I extends ZodTypeAny, C extends object, R>(props: HandlerProps<I, C, R>) => <V extends I>(input: V) => Promise<import("../types").ResponseError<unknown> | import("../types").ResponseSuccess<any>>; export {};