Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 | 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x | /**
* API Middleware Layer
*
* Reusable middleware functions for API routes.
*
* @example
* ```ts
* import {
* withAuth,
* withAdmin,
* withValidation,
* withLogging,
* compose,
* } from '@/lib/api/middleware';
*
* // Simple auth middleware
* export const GET = withAuth(async (request, context, session) => {
* return successResponse({ user: session.user });
* });
*
* // Admin with validation
* export const POST = withAdmin(async (request, context, session, user) => {
* // Only admins can access this
* return successResponse({ admin: user });
* });
*
* // Composed middleware
* export const PUT = compose(
* withLogging
* )(withValidation(updateSchema)(async (request, context, data) => {
* return successResponse(data);
* }));
* ```
*/
// Types
export type {
RouteHandler,
RouteContext,
AuthenticatedHandler,
AuthenticatedUserHandler,
AuthenticatedUser,
ValidatedHandler,
AuthValidatedHandler,
Middleware } from './types';
// Authentication middleware
export { withAuth } from './withAuth';
export { withUser } from './withUser';
export { withAdmin } from './withAdmin';
// Validation middleware
export { withValidation, parseBody } from './withValidation';
// Utility middleware
export { withLogging } from './withLogging';
// Cache headers middleware
export {
withCacheHeaders,
cachedJsonResponse,
generateETag,
checkETagMatch,
notModifiedResponse,
CACHE_PRESETS,
CachePresets,
} from './withCacheHeaders';
export type { CacheOptions } from './withCacheHeaders';
// Composition utilities
export { compose, pipe } from './compose';
// Re-export error handling from parent module
export { withErrorHandling, handleApiError } from '../errors';
|