UNPKG

@centinel/nextjs

Version:

Package designed to add Centinel Analytica functionality to Next.js applications

48 lines (47 loc) 1.57 kB
import { NextRequest, NextResponse } from 'next/server'; import { CentinelMiddleware } from './core/CentinelMiddleware'; import type { CentinelConfig } from './types'; export default function middleware(req: NextRequest): Promise<NextResponse<unknown>>; /** * Creates a Centinel middleware function with sequential validation. * The validation runs before allowing the request to proceed. * * @param config - Centinel configuration object * @returns Configured middleware function * * @example * ```typescript * // middleware.ts * import { createCentinelMiddleware } from '@centinel/nextjs'; * * export default createCentinelMiddleware({ * siteKey: process.env.CENTINEL_SITE_KEY!, * secretKey: process.env.CENTINEL_SECRET_KEY! * }); * * export const config = { * matcher: ['/api/:path*', '/dashboard/:path*'] * }; * ``` */ export declare function createCentinelMiddleware(config: CentinelConfig): (req: NextRequest) => Promise<NextResponse<unknown>>; /** * Creates a Centinel middleware function using environment variables for configuration. * * @returns Configured middleware function * * @example * ```typescript * // middleware.ts * import { createCentinelMiddlewareFromEnv } from '@centinel/nextjs'; * * export default createCentinelMiddlewareFromEnv(); * * export const config = { * matcher: ['/api/:path*', '/dashboard/:path*'] * }; * ``` */ export declare function createCentinelMiddlewareFromEnv(): (req: NextRequest) => Promise<NextResponse<unknown>>; export { CentinelMiddleware }; export type { CentinelConfig };