29 lines
811 B
TypeScript
29 lines
811 B
TypeScript
import {HTTPKernelModule} from '../HTTPKernelModule'
|
|
import {Inject, Injectable} from '../../../di'
|
|
import {HTTPKernel} from '../HTTPKernel'
|
|
import {Request} from '../../lifecycle/Request'
|
|
import {Bus} from '../../../support/bus'
|
|
|
|
/**
|
|
* HTTP kernel module that creates a request-specific event bus
|
|
* and injects it into the request container.
|
|
*/
|
|
@Injectable()
|
|
export class ClearRequestEventBusHTTPModule extends HTTPKernelModule {
|
|
@Inject()
|
|
protected bus!: Bus
|
|
|
|
public static register(kernel: HTTPKernel): void {
|
|
kernel.register(this).first()
|
|
}
|
|
|
|
public async apply(request: Request): Promise<Request> {
|
|
const requestBus = request.make<Bus>(Bus)
|
|
await requestBus.down()
|
|
|
|
// FIXME disconnect request bus from global event bus
|
|
|
|
return request
|
|
}
|
|
}
|