import type { NextFn } from '@adonisjs/core/types/http'; import { type EmitterService } from '@adonisjs/core/types'; import { type HttpContext } from '@adonisjs/core/http'; import { Session } from './session.ts'; import type { SessionConfig, SessionStoreFactory } from './types.ts'; /** * HttpContext and Redirect augmentations */ declare module '@adonisjs/core/http' { interface HttpContext { session: Session; } interface Redirect { withIntendedUrl(): Redirect; toIntended(fallback?: string): void; toIntendedRoute(...args: Parameters): void; } } /** * Session middleware is used to initiate the session store * and commit its values during an HTTP request. * * @example * // Register middleware in start/kernel.ts * server.use([ * () => import('#middleware/session_middleware') * ]) * * // Access session in route handler * Route.get('/', ({ session }) => { * session.put('visited', true) * }) */ export default class SessionMiddleware> { #private; /** * Creates a new session middleware instance * * @param config - Session configuration with store settings * @param emitter - Event emitter service */ constructor(config: SessionConfig & { store: keyof KnownStores; stores: KnownStores; }, emitter: EmitterService); /** * Handles the HTTP request by initializing session and committing changes * * @param ctx - HTTP context * @param next - Next middleware function */ handle(ctx: HttpContext, next: NextFn): Promise; }