@fdm-monster/server
Version:
FDM Monster is a bulk OctoPrint, Klipper, PrusaLink and BambuLab manager to set up, configure and monitor 3D printers. Our aim is to provide neat overview over your farm.
55 lines (54 loc) • 2.79 kB
JavaScript
import { __exportAll } from "../_virtual/_rolldown/runtime.js";
import { __decorateMetadata } from "../_virtual/_@oxc-project_runtime@0.129.0/helpers/decorateMetadata.js";
import { __decorate } from "../_virtual/_@oxc-project_runtime@0.129.0/helpers/decorate.js";
import { AppConstants } from "../server.constants.js";
import { PERMS } from "../constants/authorization.constants.js";
import { authenticate, permission } from "../middleware/authenticate.js";
import { ParamId } from "../middleware/param-converter.middleware.js";
import { PrinterCache } from "../state/printer.cache.js";
import { OctoprintClient } from "../services/octoprint/octoprint.client.js";
import { GET, POST, before, route } from "awilix-express";
//#region src/controllers/printer-settings.controller.ts
var printer_settings_controller_exports = /* @__PURE__ */ __exportAll({ PrinterSettingsController: () => PrinterSettingsController });
var _ref, _ref2;
let PrinterSettingsController = class PrinterSettingsController {
constructor(printerCache, octoprintClient) {
this.printerCache = printerCache;
this.octoprintClient = octoprintClient;
}
async get(req, res) {
const loginDto = await this.printerCache.getLoginDtoAsync(req.local.id);
const settings = await this.octoprintClient.getSettings(loginDto);
res.send(settings.data);
}
async syncPrinterName(req, res) {
const printerLogin = await this.printerCache.getLoginDtoAsync(req.local.id);
const name = await this.printerCache.getNameAsync(req.local.id);
const settings = await this.octoprintClient.updatePrinterNameSetting(printerLogin, name);
res.send(settings.data);
}
};
__decorate([
GET(),
route("/:id"),
before([permission(PERMS.PrinterSettings.Get), ParamId("id")]),
__decorateMetadata("design:type", Function),
__decorateMetadata("design:paramtypes", [Object, Object]),
__decorateMetadata("design:returntype", Promise)
], PrinterSettingsController.prototype, "get", null);
__decorate([
POST(),
route("/:id/sync-printername"),
before([ParamId("id")]),
__decorateMetadata("design:type", Function),
__decorateMetadata("design:paramtypes", [Object, Object]),
__decorateMetadata("design:returntype", Promise)
], PrinterSettingsController.prototype, "syncPrinterName", null);
PrinterSettingsController = __decorate([
route(AppConstants.apiRoute + "/printer-settings"),
before([authenticate()]),
__decorateMetadata("design:paramtypes", [typeof (_ref = typeof PrinterCache !== "undefined" && PrinterCache) === "function" ? _ref : Object, typeof (_ref2 = typeof OctoprintClient !== "undefined" && OctoprintClient) === "function" ? _ref2 : Object])
], PrinterSettingsController);
//#endregion
export { PrinterSettingsController, printer_settings_controller_exports };
//# sourceMappingURL=printer-settings.controller.js.map