UNPKG

event-local

Version:

Event client

91 lines 3.97 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const tslib_1 = require("tslib"); const EventCore_1 = require("../EventCore"); const TestService_1 = require("./TestService"); const AggregateRepository_1 = require("../AggregateRepository"); const Test_1 = require("./Test"); class TestHeandler { constructor(eventLocal) { TestHeandler.eventLocal = eventLocal; } static async createHeandler(commandDetail) { console.log(JSON.parse(commandDetail)); } static async create(req, res) { const t = await new TestService_1.default(new AggregateRepository_1.AggregateRepository(new Test_1.Test())).createTest({ id: null, name: "Anton" }); // await TestHeandler.eventLocal.sendEvent('test.created', '{"test": 1}'); console.log(t); res.send(t.getID()); } static async rename(req, res) { let id = req.params.id; let name = req.params.name; const t = await new TestService_1.default(new AggregateRepository_1.AggregateRepository(new Test_1.Test())).renameTest(id, name); // await TestHeandler.eventLocal.sendEvent('test.rename', '{"test": 1}'); console.log(t); res.send(t.getName()); } static async status(req, res) { let id = req.params.id; let status = +req.params.status; const t = await new TestService_1.default(new AggregateRepository_1.AggregateRepository(new Test_1.Test())).changeStatus(id, status); // await TestHeandler.eventLocal.sendEvent('test.rename', '{"test": 1}'); console.log(t); res.send(t.getName()); } static async get(req, res) { let id = req.params.id; const t = await new TestService_1.default(new AggregateRepository_1.AggregateRepository(new Test_1.Test())).find(id); console.log(t); res.send(JSON.stringify(t)); } static set(commandDetail) { } static myID(commandDetail) { console.log(commandDetail); } } tslib_1.__decorate([ EventCore_1.EventHeandlerMethod("test.created"), tslib_1.__metadata("design:type", Function), tslib_1.__metadata("design:paramtypes", [Object]), tslib_1.__metadata("design:returntype", Promise) ], TestHeandler, "createHeandler", null); tslib_1.__decorate([ EventCore_1.API("get", "/test/create"), tslib_1.__metadata("design:type", Function), tslib_1.__metadata("design:paramtypes", [Object, Object]), tslib_1.__metadata("design:returntype", Promise) ], TestHeandler, "create", null); tslib_1.__decorate([ EventCore_1.API("get", "/test/:id/rename/:name"), tslib_1.__metadata("design:type", Function), tslib_1.__metadata("design:paramtypes", [Object, Object]), tslib_1.__metadata("design:returntype", Promise) ], TestHeandler, "rename", null); tslib_1.__decorate([ EventCore_1.API("get", "/test/:id/status/:status"), tslib_1.__metadata("design:type", Function), tslib_1.__metadata("design:paramtypes", [Object, Object]), tslib_1.__metadata("design:returntype", Promise) ], TestHeandler, "status", null); tslib_1.__decorate([ EventCore_1.API("get", "/test/:id"), tslib_1.__metadata("design:type", Function), tslib_1.__metadata("design:paramtypes", [Object, Object]), tslib_1.__metadata("design:returntype", Promise) ], TestHeandler, "get", null); tslib_1.__decorate([ EventCore_1.MessageHeandlerMethod(/(test)/i), tslib_1.__metadata("design:type", Function), tslib_1.__metadata("design:paramtypes", [Object]), tslib_1.__metadata("design:returntype", void 0) ], TestHeandler, "set", null); tslib_1.__decorate([ EventCore_1.MessageHeandlerMethod(/(какой номер моего чата\,?)/i), tslib_1.__metadata("design:type", Function), tslib_1.__metadata("design:paramtypes", [Object]), tslib_1.__metadata("design:returntype", void 0) ], TestHeandler, "myID", null); exports.TestHeandler = TestHeandler; //# sourceMappingURL=TestHeandler.js.map