UNPKG

sipp

Version:

An Opinionated, High-Productivity MVC Web Framework in TypeScript

29 lines 1.35 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.ParamResolutionProvider = void 0; const framework_1 = require("../framework"); const http_1 = require("../http"); const async_store_1 = require("../utils/async-store"); class ParamResolutionProvider extends framework_1.ServiceProvider { register(register) { register('*', http_1.Res, () => { const req = this.withRequest(); return new http_1.Res(req, req.res); }); register('*', http_1.Req, () => { const req = this.withRequest(); return new http_1.Req(req); }); register('*', http_1.Body, (_, Type) => new Type(this.withRequest().body)); register('*', http_1.Headers, (_, Type) => new Type(this.withRequest().headers)); register('*', http_1.Params, (_, Type) => new Type(this.withRequest().params)); register('*', http_1.Query, (_, Type) => new Type(this.withRequest().query)); register('*', http_1.Session, () => new http_1.Session(this.withRequest())); register('*', http_1.Csrf, () => new http_1.Csrf(this.withRequest())); } withRequest() { return async_store_1.getStore().get("__REQ_KEY__"); } } exports.ParamResolutionProvider = ParamResolutionProvider; //# sourceMappingURL=ParamResolutionProvider.js.map