UNPKG

zents

Version:

ZenTS is a Node.js & TypeScript MVC-Framework for building rich web applications, released as free and open-source software under the MIT License. It is designed for building web applications with modern tools and design patterns.

35 lines 1.43 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.SessionAction = void 0; const AbstractAction_1 = require("./AbstractAction"); const enums_1 = require("../../types/enums"); const isObject_1 = require("../../utils/isObject"); class SessionAction extends AbstractAction_1.AbstractAction { constructor(injector, context, loadedUser, injectedSessions) { super(injector); this.context = context; this.loadedUser = loadedUser; this.injectedSessions = injectedSessions; } async run(instance, method) { if (!Reflect.hasMetadata(enums_1.REFLECT_METADATA.SESSION, instance, method)) { return []; } const factory = this.injector.context.getSessionFactory(); const metadata = Reflect.getMetadata(enums_1.REFLECT_METADATA.SESSION, instance, method); const parameters = []; for (const meta of metadata) { const session = await factory.build(meta.name, this.context, isObject_1.isObject(this.loadedUser) && this.loadedUser.provider === meta.name ? this.loadedUser : undefined); this.injectedSessions.push(session); parameters.push({ index: meta.index, value: session, }); } return parameters; } } exports.SessionAction = SessionAction; //# sourceMappingURL=SessionAction.js.map