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()
|
2021-03-08 15:00:43 +00:00
|
|
|
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
|
|
|
|
}
|
|
|
|
}
|