lib/src/http/kernel/module/PersistSessionHTTPModule.ts

21 lines
641 B
TypeScript
Raw Normal View History

2021-03-07 19:26:14 +00:00
import {HTTPKernelModule} from "../HTTPKernelModule";
import {Injectable} from "@extollo/di"
import {HTTPKernel} from "../HTTPKernel";
import {Request} from "../../lifecycle/Request";
import {Session} from "../../session/Session";
@Injectable()
export class PersistSessionHTTPModule extends HTTPKernelModule {
2021-03-09 15:42:19 +00:00
public readonly executeWithBlockingWriteback = true
2021-03-07 19:26:14 +00:00
public static register(kernel: HTTPKernel) {
kernel.register(this).last()
}
public async apply(request: Request): Promise<Request> {
const session = <Session> request.make(Session)
await session.persist()
return request
}
}