UNPKG

@fdm-monster/server

Version:

FDM Monster is a bulk OctoPrint manager to set up, configure and monitor 3D printers. Our aim is to provide extremely optimized websocket performance and reliability.

127 lines (126 loc) 5.51 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); Object.defineProperty(exports, "CameraStreamController", { enumerable: true, get: function() { return CameraStreamController; } }); const _awilixroutercore = require("awilix-router-core"); const _serverconstants = require("../server.constants"); const _authenticate = require("../middleware/authenticate"); const _express = require("express"); const _camerastreamserviceinterface = require("../services/interfaces/camera-stream.service.interface"); const _authorizationconstants = require("../constants/authorization.constants"); const _paramconvertermiddleware = require("../middleware/param-converter.middleware"); function _ts_decorate(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; } function _ts_metadata(k, v) { if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v); } class CameraStreamController { cameraStreamService; constructor(cameraStreamService){ this.cameraStreamService = cameraStreamService; } async list(req, res) { const result = await this.cameraStreamService.list(); res.send(result.map((item)=>this.cameraStreamService.toDto(item))); } async get(req, res) { const result = await this.cameraStreamService.get(req.local.id); res.send(this.cameraStreamService.toDto(result)); } async create(req, res) { const result = await this.cameraStreamService.create(req.body); res.send(this.cameraStreamService.toDto(result)); } async update(req, res) { const result = await this.cameraStreamService.update(req.local.id, req.body); res.send(this.cameraStreamService.toDto(result)); } async delete(req, res) { await this.cameraStreamService.delete(req.local.id); res.send(); } } _ts_decorate([ (0, _awilixroutercore.GET)(), (0, _awilixroutercore.route)("/"), _ts_metadata("design:type", Function), _ts_metadata("design:paramtypes", [ typeof _express.Request === "undefined" ? Object : _express.Request, typeof _express.Response === "undefined" ? Object : _express.Response ]), _ts_metadata("design:returntype", Promise) ], CameraStreamController.prototype, "list", null); _ts_decorate([ (0, _awilixroutercore.GET)(), (0, _awilixroutercore.route)("/:id"), (0, _awilixroutercore.before)([ (0, _paramconvertermiddleware.ParamId)("id") ]), _ts_metadata("design:type", Function), _ts_metadata("design:paramtypes", [ typeof _express.Request === "undefined" ? Object : _express.Request, typeof _express.Response === "undefined" ? Object : _express.Response ]), _ts_metadata("design:returntype", Promise) ], CameraStreamController.prototype, "get", null); _ts_decorate([ (0, _awilixroutercore.POST)(), (0, _awilixroutercore.route)("/"), _ts_metadata("design:type", Function), _ts_metadata("design:paramtypes", [ typeof _express.Request === "undefined" ? Object : _express.Request, typeof _express.Response === "undefined" ? Object : _express.Response ]), _ts_metadata("design:returntype", Promise) ], CameraStreamController.prototype, "create", null); _ts_decorate([ (0, _awilixroutercore.PUT)(), (0, _awilixroutercore.route)("/:id"), (0, _awilixroutercore.before)([ (0, _paramconvertermiddleware.ParamId)("id") ]), _ts_metadata("design:type", Function), _ts_metadata("design:paramtypes", [ typeof _express.Request === "undefined" ? Object : _express.Request, typeof _express.Response === "undefined" ? Object : _express.Response ]), _ts_metadata("design:returntype", Promise) ], CameraStreamController.prototype, "update", null); _ts_decorate([ (0, _awilixroutercore.DELETE)(), (0, _awilixroutercore.route)("/:id"), (0, _awilixroutercore.before)([ (0, _paramconvertermiddleware.ParamId)("id") ]), _ts_metadata("design:type", Function), _ts_metadata("design:paramtypes", [ typeof _express.Request === "undefined" ? Object : _express.Request, typeof _express.Response === "undefined" ? Object : _express.Response ]), _ts_metadata("design:returntype", Promise) ], CameraStreamController.prototype, "delete", null); CameraStreamController = _ts_decorate([ (0, _awilixroutercore.route)(`${_serverconstants.AppConstants.apiRoute}/camera-stream`), (0, _awilixroutercore.before)([ (0, _authenticate.authenticate)(), (0, _authenticate.authorizeRoles)([ _authorizationconstants.ROLES.OPERATOR, _authorizationconstants.ROLES.ADMIN ]) ]), _ts_metadata("design:type", Function), _ts_metadata("design:paramtypes", [ typeof _camerastreamserviceinterface.ICameraStreamService === "undefined" ? Object : _camerastreamserviceinterface.ICameraStreamService ]) ], CameraStreamController); //# sourceMappingURL=camera-stream.controller.js.map