@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.
110 lines (109 loc) • 4.66 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 { isNode } from "../utils/env.utils.js";
import { SettingsStore } from "../state/settings.store.js";
import { ServerReleaseService } from "../services/core/server-release.service.js";
import { PERMS } from "../constants/authorization.constants.js";
import { authenticate, permission } from "../middleware/authenticate.js";
import { MonsterPiService } from "../services/core/monsterpi.service.js";
import { GET, before, route } from "awilix-express";
//#region src/controllers/server-public.controller.ts
var server_public_controller_exports = /* @__PURE__ */ __exportAll({ ServerPublicController: () => ServerPublicController });
var _ref, _ref2, _ref3;
let ServerPublicController = class ServerPublicController {
constructor(settingsStore, serverVersion, serverReleaseService, monsterPiService) {
this.settingsStore = settingsStore;
this.serverVersion = serverVersion;
this.serverReleaseService = serverReleaseService;
this.monsterPiService = monsterPiService;
}
async welcome(req, res) {
this.settingsStore.getSettings();
if (!await this.settingsStore.getLoginRequired()) return res.send({
message: "Login disabled. Please load the Vue app.",
apiDocs: "http://localhost:4000/api-docs/",
swaggerJson: "http://localhost:4000/api-docs/swagger.json"
});
return res.send({
message: "Login required. Please load the Vue app.",
apiDocs: "http://localhost:4000/api-docs/",
swaggerJson: "http://localhost:4000/api-docs/swagger.json"
});
}
getFeatures(req, res) {
const serverSettings = this.settingsStore.getServerSettings();
const moonrakerEnabled = serverSettings.experimentalMoonrakerSupport;
const prusaLinkEnabled = serverSettings.experimentalPrusaLinkSupport;
const bambuEnabled = serverSettings.experimentalBambuSupport;
res.send({ multiplePrinterServices: {
available: true,
version: 1,
subFeatures: { types: [
"octoprint",
...moonrakerEnabled ? ["klipper"] : [],
...prusaLinkEnabled ? ["prusaLink"] : [],
...bambuEnabled ? ["bambu"] : []
] }
} });
}
async getVersion(req, res) {
const updateState = this.serverReleaseService.getState();
const monsterPiVersion = this.monsterPiService.getMonsterPiVersionSafe();
res.json({
version: this.serverVersion,
isNode: isNode(),
os: process.env.OS,
monsterPi: monsterPiVersion,
update: {
synced: updateState.synced,
updateAvailable: updateState.updateAvailable,
airGapped: updateState.airGapped
}
});
}
async test(req, res) {
res.send({ message: "Test successful. Please load the Vue app." });
}
};
__decorate([
GET(),
route("/"),
before([authenticate(), permission(PERMS.ServerInfo.Get)]),
__decorateMetadata("design:type", Function),
__decorateMetadata("design:paramtypes", [Object, Object]),
__decorateMetadata("design:returntype", Promise)
], ServerPublicController.prototype, "welcome", null);
__decorate([
GET(),
route("/features"),
before([authenticate()]),
__decorateMetadata("design:type", Function),
__decorateMetadata("design:paramtypes", [Object, Object]),
__decorateMetadata("design:returntype", void 0)
], ServerPublicController.prototype, "getFeatures", null);
__decorate([
GET(),
route("/version"),
before([authenticate(), permission(PERMS.ServerInfo.Get)]),
__decorateMetadata("design:type", Function),
__decorateMetadata("design:paramtypes", [Object, Object]),
__decorateMetadata("design:returntype", Promise)
], ServerPublicController.prototype, "getVersion", null);
__decorate([
GET(),
route("/test"),
__decorateMetadata("design:type", Function),
__decorateMetadata("design:paramtypes", [Object, Object]),
__decorateMetadata("design:returntype", Promise)
], ServerPublicController.prototype, "test", null);
ServerPublicController = __decorate([route(AppConstants.apiRoute), __decorateMetadata("design:paramtypes", [
typeof (_ref = typeof SettingsStore !== "undefined" && SettingsStore) === "function" ? _ref : Object,
String,
typeof (_ref2 = typeof ServerReleaseService !== "undefined" && ServerReleaseService) === "function" ? _ref2 : Object,
typeof (_ref3 = typeof MonsterPiService !== "undefined" && MonsterPiService) === "function" ? _ref3 : Object
])], ServerPublicController);
//#endregion
export { ServerPublicController, server_public_controller_exports };
//# sourceMappingURL=server-public.controller.js.map