UNPKG

@novu/framework

Version:

The Code-First Notifications Workflow SDK.

48 lines (45 loc) 1.9 kB
import { NextRequest } from 'next/server'; import { S as ServeHandlerOptions } from '../index-S0QKfWxm.cjs'; export { C as Client, N as NovuRequestHandler, w as workflow } from '../index-S0QKfWxm.cjs'; export { C as CronExpression, S as SeverityLevelEnum, W as Workflow, p as providerSchemas } from '../health-check.types-D_KcRiM_.cjs'; import { S as SupportedFrameworkName } from '../server.types-BRWsA1CA.cjs'; import 'json-schema-to-ts'; import 'zod'; declare const frameworkName: SupportedFrameworkName; /** * Defines a request handler for Next.js 12+. * * The argument types are kept abstract due to varying type checks across * Next.js versions. Next.js 15 uses `RouteContext` for the second argument, * while versions 13 and 14 omit it, and version 12 uses `NextApiResponse`, * which varies by environment (edge vs serverless). */ type RequestHandler = (expectedReq: NextRequest, res: unknown) => Promise<Response>; /** * In Next.js, serve and register any declared workflows with Novu, making * them available to be triggered by events. * * Supports Next.js 12+, both serverless and edge. * * @example Next.js <=12 or the pages router can export the handler directly * ```ts * import { serve } from "@novu/framework/next"; * import { myWorkflow } from "./src/novu/workflows"; // Your workflows * * export default serve({ workflows: [myWorkflow] }); * ``` * * @example Next.js >=13 with the `app` dir must export individual methods * ```ts * import { serve } from "@novu/framework/next"; * import { myWorkflow } from "./src/novu/workflows"; * * export const { GET, POST, OPTIONS } = serve({ workflows: [myWorkflow] }); * ``` */ declare const serve: (options: ServeHandlerOptions) => RequestHandler & { GET: RequestHandler; POST: RequestHandler; OPTIONS: RequestHandler; }; export { type RequestHandler, ServeHandlerOptions, frameworkName, serve };