import { getTask, taskSchema } from "../../data/index.js";
import { authenticate } from "../authentication.js";
import { isUnauthenticated } from "../../authentication/index.js";
export async function getTaskRoutes(fastify) {
    const params = {
        type: "object",
        properties: {
            taskId: {
                type: "string",
            },
        },
        required: ["taskId"],
    };
    const response = {
        200: {
            description: "A task",
            ...taskSchema.task,
        },
    };
    const schema = {
        description: "Get a task",
        tags: ["task"],
        summary: "",
        response,
        params,
        security: [
            {
                apiKey: [],
            },
        ],
    };
    try {
        fastify.get("/:taskId", {
            schema,
            preHandler: authenticate(fastify),
            async handler(request, response) {
                const task = await getTask(request.params.taskId);
                if (!task || (isUnauthenticated() || !task.public))
                    response.status(404);
                response.send(task);
            },
        });
    }
    catch { }
}
//# sourceMappingURL=get-task.js.map