"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.default = dashboardRoutes;
async function dashboardRoutes(fastify) {
    fastify.get("/getInfo/:projectId", async (req) => {
        const { projectId } = req.params;
        return await fastify.core.dashboard.getOrCreate(projectId);
    });
    fastify.post("/update/:projectId", async (req) => {
        const { projectId } = req.params;
        const body = req.body;
        return await fastify.core.dashboard.saveWithConflictCheck(projectId, body);
    });
    fastify.get("/widgets/:projectId", async (req) => {
        const { projectId } = req.params;
        return await fastify.core.dashboard.getAvailableWidgets(projectId);
    });
    fastify.get("/addWidget/:projectId/:widgetKey/:x/:y", async (req) => {
        let { projectId, widgetKey, x, y } = req.params;
        x = Number(x) || 0;
        y = Number(y) || 0;
        return await fastify.core.dashboard.addWidget(projectId, widgetKey, x, y);
    });
    fastify.delete("/removeWidget/:projectId/:widgetId", async (req) => {
        const { projectId, widgetId } = req.params;
        return await fastify.core.dashboard.removeWidget(projectId, widgetId);
    });
    fastify.post("/updateItemConfig/:projectId/:widgetId", async (req) => {
        const { projectId, widgetId } = req.params;
        const config = req.body;
        return await fastify.core.dashboard.updateItemConfig(projectId, widgetId, config);
    });
    fastify.get("/killPort/:port", async (req) => {
        const { port } = req.params;
        return await fastify.core.dashboard.killPort(Number(port));
    });
}
