@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.
68 lines (67 loc) • 2.32 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", {
value: true
});
Object.defineProperty(exports, "CameraStreamService", {
enumerable: true,
get: function() {
return CameraStreamService;
}
});
const _models = require("../../models");
const _validators = require("../../handlers/validators");
const _runtimeexceptions = require("../../exceptions/runtime.exceptions");
const _cameraservicevalidation = require("../validators/camera-service.validation");
class CameraStreamService {
printerCache;
model;
constructor(printerCache){
this.printerCache = printerCache;
this.model = _models.CameraStream;
}
async list() {
return this.model.find();
}
async get(id) {
const cameraStream = await this.model.findById(id);
if (!cameraStream) {
throw new _runtimeexceptions.NotFoundException(`Floor with provided id does not exist`, "CameraStream");
}
return cameraStream;
}
async create(data) {
const input = await (0, _validators.validateInput)(data, (0, _cameraservicevalidation.createCameraStreamSchema)(false));
if (input.printerId) {
this.printerCache.getCachedPrinterOrThrow(input.printerId);
}
return this.model.create(input);
}
async delete(id) {
await this.get(id);
await this.model.findByIdAndDelete(id);
}
async update(id, input) {
await this.get(id);
const updateInput = await (0, _validators.validateInput)(input, (0, _cameraservicevalidation.createCameraStreamSchema)(false));
if (input.printerId) {
this.printerCache.getCachedPrinterOrThrow(input.printerId);
}
await this.model.updateOne({
id
}, updateInput);
return this.get(id);
}
toDto(entity) {
return {
id: entity.id,
streamURL: entity.streamURL,
printerId: !entity?.printerId ? null : entity.printerId.toString(),
name: entity.name,
aspectRatio: entity.aspectRatio,
flipHorizontal: entity.flipHorizontal,
flipVertical: entity.flipVertical,
rotationClockwise: entity.rotationClockwise
};
}
}
//# sourceMappingURL=camera-stream.service.js.map