import { type HttpContext } from '@adonisjs/core/http';
import type { NextFn } from '@adonisjs/core/types/http';
import type { CorsConfig } from './types.ts';
/**
 * The Cors middleware class to handle preflight request as per the CORS
 * RFC https://www.w3.org/TR/cors/.
 *
 * This is a functional middleware and shared among all requests. So make
 * sure not to set request specific instance properties.
 *
 * @example
 * ```ts
 * const corsMiddleware = new CorsMiddleware({
 *   enabled: true,
 *   origin: ['http://localhost:3000'],
 *   methods: ['GET', 'POST'],
 *   headers: true,
 *   credentials: false,
 *   maxAge: 90
 * })
 *
 * await corsMiddleware.handle(ctx, next)
 * ```
 */
export default class CorsMiddleware {
    #private;
    /**
     * Create a new instance of CorsMiddleware
     *
     * @param config - The CORS configuration object
     */
    constructor(config: CorsConfig);
    /**
     * Handle HTTP request for CORS. This method is binded as a before hook
     * to the HTTP server.
     *
     * @param ctx - The HTTP context containing request and response
     * @param next - The next function to call in the middleware chain
     *
     * @example
     * ```ts
     * await corsMiddleware.handle(ctx, next)
     * ```
     */
    handle(ctx: HttpContext, next: NextFn): Promise<any>;
}
