"use strict";
Object.defineProperty(exports, "__esModule", {
    value: true
});
function _export(target, all) {
    for(var name in all)Object.defineProperty(target, name, {
        enumerable: true,
        get: all[name]
    });
}
_export(exports, {
    CameraStreamController: function() {
        return CameraStreamController;
    },
    default: function() {
        return _default;
    }
});
const _awilixexpress = require("awilix-express");
const _serverconstants = require("../server.constants");
const _validators = require("../handlers/validators");
const _genericvalidation = require("./validation/generic.validation");
const _authenticate = require("../middleware/authenticate");
class CameraStreamController {
    cameraStreamService;
    isTypeormMode;
    constructor({ cameraStreamService, isTypeormMode }){
        this.cameraStreamService = cameraStreamService;
        this.isTypeormMode = isTypeormMode;
    }
    async list(req, res) {
        const result = await this.cameraStreamService.list();
        res.send(result.map((item)=>this.cameraStreamService.toDto(item)));
    }
    async get(req, res) {
        const { id } = await (0, _validators.validateInput)(req.params, (0, _genericvalidation.idRulesV2)(this.isTypeormMode));
        const result = await this.cameraStreamService.get(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 { id } = await (0, _validators.validateInput)(req.params, (0, _genericvalidation.idRulesV2)(this.isTypeormMode));
        const result = await this.cameraStreamService.update(id, req.body);
        res.send(this.cameraStreamService.toDto(result));
    }
    async delete(req, res) {
        const { id } = await (0, _validators.validateInput)(req.params, (0, _genericvalidation.idRulesV2)(this.isTypeormMode));
        await this.cameraStreamService.delete(id);
        res.send();
    }
}
const _default = (0, _awilixexpress.createController)(CameraStreamController).prefix(_serverconstants.AppConstants.apiRoute + "/camera-stream").before([
    (0, _authenticate.authenticate)()
]).get("/", "list").get("/:id", "get").post("/", "create").delete("/:id", "delete").put("/:id", "update");

//# sourceMappingURL=camera-stream.controller.js.map