import {HTTPKernelModule} from '../HTTPKernelModule' import {Injectable} from '../../../di' import {HTTPKernel} from '../HTTPKernel' import {Request} from '../../lifecycle/Request' import {Session} from '../../session/Session' /** * HTTP kernel module that runs after the main logic in the request to persist * the session data to the driver's backend. */ @Injectable() export class PersistSessionHTTPModule extends HTTPKernelModule { public readonly executeWithBlockingWriteback = true public static register(kernel: HTTPKernel): void { kernel.register(this).last() } public async apply(request: Request): Promise { const session = request.make(Session) await session.persist() return request } }