You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
lib/src/http/kernel/module/PersistSessionHTTPModule.ts

25 lines
775 B

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<Request> {
const session = <Session> request.make(Session)
await session.persist()
return request
}
}