UNPKG

@methodus/server

Version:
204 lines 9.5 kB
"use strict"; var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; return c > 3 && r && Object.defineProperty(target, key, r), r; }; var __metadata = (this && this.__metadata) || function (k, v) { if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v); }; var __param = (this && this.__param) || function (paramIndex, decorator) { return function (target, key) { decorator(target, key, paramIndex); } }; var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { return new (P || (P = Promise))(function (resolve, reject) { function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); } step((generator = generator.apply(thisArg, _arguments || [])).next()); }); }; Object.defineProperty(exports, "__esModule", { value: true }); const index_1 = require("../../index"); const M = require("../../index"); const fs = require("fs"); process.env.methodus_name = 'first-class'; let FirstClass = class FirstClass { constructor() { } getFile(id, name) { const stream = fs.createReadStream('./image.jpg'); let result = new index_1.MethodResult(stream); return result; } action1(id, name) { let result = new index_1.MethodResult({ value: 'FirstClass Dataasdasd', id: id, name: name, add: 'added' }); return result; } action2Function(id, name, size) { let result = new index_1.MethodResult({ value: 'actionQuery', id: id, name: name, add: 'added', size: size }); return result; } action3Function(action, size, length) { return __awaiter(this, void 0, void 0, function* () { let result = new index_1.MethodResult({ value: size * length, size: size, length: length }); return result; }); } action4(action, size, length) { return __awaiter(this, void 0, void 0, function* () { let result = new index_1.MethodResult({ value: size * length, size: size, length: length }); return result; }); } action5(action, size, length) { return __awaiter(this, void 0, void 0, function* () { let result = new index_1.MethodResult({ value: size * length, size: size, length: length }); return result; }); } dateAction(action, start, end) { return __awaiter(this, void 0, void 0, function* () { let result = new index_1.MethodResult({ value: start, size: Date }); return result; }); } action6(action, file, length) { return __awaiter(this, void 0, void 0, function* () { let result = new index_1.MethodResult({ value: file, length: length }); return result; }); } testheaders(id, name) { let result = new index_1.MethodResult({ value: 'actionQuery', id: id, name: name, add: 'added' }); return result; } actionQuery(id, name) { let result = new index_1.MethodResult({ value: 'actionQuery', id: id, name: name, add: 'added' }); return result; } error() { console.log('running error localy'); throw (new index_1.MethodError('error returned', 500)); } denied() { console.log('running denied localy'); throw (new index_1.MethodError('denied returned', 401)); } EventHandler(value) { console.log('handling events in handler', value); } action2(item) { return new index_1.MethodResult({ item }); } action3() { console.log('action3'); } }; __decorate([ index_1.MethodPipe("GET" /* Get */, '/posts/:id/:name'), __param(0, index_1.Param('id')), __param(1, index_1.Param('name')), __metadata("design:type", Function), __metadata("design:paramtypes", [Number, String]), __metadata("design:returntype", void 0) ], FirstClass.prototype, "getFile", null); __decorate([ index_1.Method("GET" /* Get */, '/posts/:id/:name'), __param(0, index_1.Param('id')), __param(1, index_1.Param('name')), __metadata("design:type", Function), __metadata("design:paramtypes", [Number, String]), __metadata("design:returntype", void 0) ], FirstClass.prototype, "action1", null); __decorate([ index_1.Method("GET" /* Get */, '/action2/:id/:name'), __param(0, index_1.Param('id')), __param(1, index_1.Param('name')), __param(2, index_1.Query('size')), __metadata("design:type", Function), __metadata("design:paramtypes", [Number, String, Number]), __metadata("design:returntype", void 0) ], FirstClass.prototype, "action2Function", null); __decorate([ index_1.Method("POST" /* Post */, '/api/action3/xaction/:action'), __param(0, index_1.Param('action')), __param(1, index_1.Query('size')), __param(2, index_1.Body('length')), __metadata("design:type", Function), __metadata("design:paramtypes", [Object, Object, Object]), __metadata("design:returntype", Promise) ], FirstClass.prototype, "action3Function", null); __decorate([ M.Method("POST" /* Post */, '/api/action4/xaction/:action'), __param(0, M.Param('action')), __param(1, M.Headers('Referer')), __param(2, M.Body('length')), __metadata("design:type", Function), __metadata("design:paramtypes", [Object, Object, Object]), __metadata("design:returntype", Promise) ], FirstClass.prototype, "action4", null); __decorate([ M.Method("POST" /* Post */, '/api/action5/xaction/:action'), __param(0, M.Param('action')), __param(1, M.Cookies('Size')), __param(2, M.Body('length')), __metadata("design:type", Function), __metadata("design:paramtypes", [Object, Object, Object]), __metadata("design:returntype", Promise) ], FirstClass.prototype, "action5", null); __decorate([ M.Method("POST" /* Post */, '/api/dateaction/xaction/:action'), __param(0, M.Param('action')), __param(1, M.Query('start')), __param(2, M.Query('end')), __metadata("design:type", Function), __metadata("design:paramtypes", [Object, Date, Date]), __metadata("design:returntype", Promise) ], FirstClass.prototype, "dateAction", null); __decorate([ M.Method("POST" /* Post */, '/api/action6/xaction/:action'), __param(0, M.Param('action')), __param(1, M.Files('file')), __param(2, M.Body('length')), __metadata("design:type", Function), __metadata("design:paramtypes", [Object, Object, Object]), __metadata("design:returntype", Promise) ], FirstClass.prototype, "action6", null); __decorate([ index_1.Method("POST" /* Post */, '/testheaders/'), __param(0, index_1.Body('id')), __param(1, index_1.Headers('name-name')), __metadata("design:type", Function), __metadata("design:paramtypes", [Number, Object]), __metadata("design:returntype", void 0) ], FirstClass.prototype, "testheaders", null); __decorate([ index_1.Method("GET" /* Get */, '/posts/'), __param(0, index_1.Query('id')), __param(1, index_1.Query('name')), __metadata("design:type", Function), __metadata("design:paramtypes", [Number, String]), __metadata("design:returntype", void 0) ], FirstClass.prototype, "actionQuery", null); __decorate([ index_1.Method("GET" /* Get */, '/posts/error'), __metadata("design:type", Function), __metadata("design:paramtypes", []), __metadata("design:returntype", void 0) ], FirstClass.prototype, "error", null); __decorate([ index_1.Method("GET" /* Get */, '/posts/denied'), __metadata("design:type", Function), __metadata("design:paramtypes", []), __metadata("design:returntype", void 0) ], FirstClass.prototype, "denied", null); __decorate([ index_1.MessageHandler('FirstClassEvent', 'event-bus'), __metadata("design:type", Function), __metadata("design:paramtypes", [Object]), __metadata("design:returntype", void 0) ], FirstClass.prototype, "EventHandler", null); __decorate([ index_1.Method("POST" /* Post */, '/posts/'), __param(0, index_1.Body('data')), __metadata("design:type", Function), __metadata("design:paramtypes", [Object]), __metadata("design:returntype", void 0) ], FirstClass.prototype, "action2", null); __decorate([ index_1.Method("DELETE" /* Delete */, 'api/acion1'), __metadata("design:type", Function), __metadata("design:paramtypes", []), __metadata("design:returntype", void 0) ], FirstClass.prototype, "action3", null); FirstClass = __decorate([ index_1.MethodConfig('FirstClass'), __metadata("design:paramtypes", []) ], FirstClass); exports.FirstClass = FirstClass; //# sourceMappingURL=FirstClass.js.map