@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.
50 lines (49 loc) • 1.56 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", {
value: true
});
Object.defineProperty(exports, "CustomGcodeService", {
enumerable: true,
get: function() {
return CustomGcodeService;
}
});
const _models = require("../../models");
const _runtimeexceptions = require("../../exceptions/runtime.exceptions");
class CustomGcodeService {
toDto(document) {
return {
id: document.id,
name: document.name,
description: document.description,
gcode: [
...document.gcode
]
};
}
async get(gcodeScriptId) {
const document = await _models.CustomGcode.findById(gcodeScriptId);
if (!document) {
throw new _runtimeexceptions.NotFoundException(`Custom GCode script with provided id does not exist`);
}
return document;
}
async list() {
return _models.CustomGcode.find();
}
async create(gcodeScript) {
return _models.CustomGcode.create(gcodeScript);
}
async delete(gcodeScriptId) {
const gcode = await this.get(gcodeScriptId);
await _models.CustomGcode.findByIdAndDelete(gcode.id);
}
async update(gcodeScriptId, updatedData) {
const customGcode = await this.get(gcodeScriptId);
customGcode.name = updatedData.name;
customGcode.description = updatedData.description;
customGcode.gcode = updatedData.gcode;
return await customGcode.save();
}
}
//# sourceMappingURL=custom-gcode.service.js.map