UNPKG

@tsed/common

Version:
43 lines 1.52 kB
"use strict"; var PlatformApplication_1; Object.defineProperty(exports, "__esModule", { value: true }); exports.PlatformApplication = void 0; const tslib_1 = require("tslib"); const di_1 = require("@tsed/di"); const createContext_1 = require("../utils/createContext"); const FakeRawDriver_1 = require("./FakeRawDriver"); const PlatformHandler_1 = require("./PlatformHandler"); const PlatformRouter_1 = require("./PlatformRouter"); /** * `PlatformApplication` is used to provide all routes collected by annotation `@Controller`. * * @platform */ let PlatformApplication = PlatformApplication_1 = class PlatformApplication extends PlatformRouter_1.PlatformRouter { constructor(platformHandler) { super(platformHandler); this.rawApp = this.raw = PlatformApplication_1.createRawApp(); } static createRawApp() { return FakeRawDriver_1.createFakeRawDriver(); } getApp() { return this.raw; } useContext() { // @ts-ignore this.getApp().use(async (req, res, next) => { await createContext_1.createContext(this.injector, req, res); next(); }); return this; } }; PlatformApplication = PlatformApplication_1 = tslib_1.__decorate([ di_1.Injectable({ scope: di_1.ProviderScope.SINGLETON }), tslib_1.__metadata("design:paramtypes", [PlatformHandler_1.PlatformHandler]) ], PlatformApplication); exports.PlatformApplication = PlatformApplication; //# sourceMappingURL=PlatformApplication.js.map