"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const express_1 = require("express");
const zod_1 = require("zod");
const task_controller_1 = require("../controllers/task.controller");
const validation_middleware_1 = require("../middleware/validation.middleware");
const rateLimit_middleware_1 = require("../middleware/rateLimit.middleware");
const task_validator_1 = require("../validators/task.validator");
const router = (0, express_1.Router)();
const taskController = new task_controller_1.TaskController();
// UUID validation schema for params
const UuidParamsSchema = zod_1.z.object({
    id: zod_1.z.string().uuid()
});
/**
 * @route   GET /api/tasks
 * @desc    Get all tasks with pagination and filtering
 * @access  Public
 */
router.get('/', rateLimit_middleware_1.generalLimiter, (0, validation_middleware_1.validate)(task_validator_1.TaskQuerySchema, 'query'), (req, res) => taskController.getTasks(req, res));
/**
 * @route   GET /api/tasks/:id
 * @desc    Get a single task by ID
 * @access  Public
 */
router.get('/:id', rateLimit_middleware_1.generalLimiter, (0, validation_middleware_1.validate)(UuidParamsSchema, 'params'), (req, res) => taskController.getTaskById(req, res));
/**
 * @route   POST /api/tasks
 * @desc    Create a new task
 * @access  Public
 */
router.post('/', rateLimit_middleware_1.strictLimiter, (0, validation_middleware_1.validate)(task_validator_1.CreateTaskSchema, 'body'), (req, res) => taskController.createTask(req, res));
/**
 * @route   PUT /api/tasks/:id
 * @desc    Update a task
 * @access  Public
 */
router.put('/:id', rateLimit_middleware_1.strictLimiter, (0, validation_middleware_1.validateMultiple)({
    params: UuidParamsSchema,
    body: task_validator_1.UpdateTaskSchema
}), (req, res) => taskController.updateTask(req, res));
/**
 * @route   PATCH /api/tasks/:id
 * @desc    Partially update a task
 * @access  Public
 */
router.patch('/:id', rateLimit_middleware_1.strictLimiter, (0, validation_middleware_1.validateMultiple)({
    params: UuidParamsSchema,
    body: task_validator_1.UpdateTaskSchema
}), (req, res) => taskController.updateTask(req, res));
/**
 * @route   DELETE /api/tasks/:id
 * @desc    Delete a task
 * @access  Public
 */
router.delete('/:id', rateLimit_middleware_1.strictLimiter, (0, validation_middleware_1.validate)(UuidParamsSchema, 'params'), (req, res) => taskController.deleteTask(req, res));
/**
 * @route   POST /api/tasks/bulk/create
 * @desc    Bulk create tasks
 * @access  Public
 */
router.post('/bulk/create', rateLimit_middleware_1.bulkLimiter, (0, validation_middleware_1.validate)(task_validator_1.BulkCreateTasksSchema, 'body'), (req, res) => taskController.bulkCreateTasks(req, res));
/**
 * @route   PUT /api/tasks/bulk/update
 * @desc    Bulk update tasks
 * @access  Public
 */
router.put('/bulk/update', rateLimit_middleware_1.bulkLimiter, (0, validation_middleware_1.validate)(task_validator_1.BulkUpdateTasksSchema, 'body'), (req, res) => taskController.bulkUpdateTasks(req, res));
/**
 * @route   DELETE /api/tasks/bulk/delete
 * @desc    Bulk delete tasks
 * @access  Public
 */
router.delete('/bulk/delete', rateLimit_middleware_1.bulkLimiter, (0, validation_middleware_1.validate)(task_validator_1.BulkDeleteTasksSchema, 'body'), (req, res) => taskController.bulkDeleteTasks(req, res));
/**
 * @route   POST /api/tasks/duplicate
 * @desc    Duplicate a task
 * @access  Public
 */
router.post('/duplicate', rateLimit_middleware_1.strictLimiter, (0, validation_middleware_1.validate)(task_validator_1.DuplicateTaskSchema, 'body'), (req, res) => taskController.duplicateTask(req, res));
/**
 * @route   POST /api/tasks/template/create
 * @desc    Create a template from a task
 * @access  Public
 */
router.post('/template/create', rateLimit_middleware_1.templateLimiter, (0, validation_middleware_1.validate)(task_validator_1.CreateTemplateFromTaskSchema, 'body'), (req, res) => taskController.createTemplateFromTask(req, res));
/**
 * @route   POST /api/tasks/template/apply
 * @desc    Apply a template to create a new task
 * @access  Public
 */
router.post('/template/apply', rateLimit_middleware_1.templateLimiter, (0, validation_middleware_1.validate)(task_validator_1.ApplyTemplateSchema, 'body'), (req, res) => taskController.applyTemplate(req, res));
exports.default = router;
//# sourceMappingURL=task.routes.js.map