import { addTask, taskSchema } from "../../data/index.js";
import { authenticate } from "../authentication.js";
export async function addTaskRoutes(fastify) {
    const response = {
        201: {
            description: "A new task",
            ...taskSchema.task,
        },
    };
    const schema = {
        description: "Add a new task",
        tags: ["task"],
        summary: "",
        body: taskSchema.taskData,
        response,
        security: [
            {
                apiKey: [],
            },
        ],
    };
    try {
        fastify.post("/", {
            schema,
            preHandler: authenticate(fastify),
            async handler(request, response) {
                const task = await addTask(request.body);
                response.status(201);
                response.send(task);
            },
        });
    }
    catch { }
}
//# sourceMappingURL=add-task.js.map