/**
 * {{featureName}} Feature Routes - Express endpoints with AppKit integration
 * @module {{projectName}}/{{featureName}}-routes
 * @file src/api/features/{{featureName}}/{{featureName}}.route.ts
 *
 * @llm-rule WHEN: Need HTTP endpoints for {{featureName}} feature with error handling
 * @llm-rule AVOID: Adding routes without asyncRoute wrapper - breaks error handling
 * @llm-rule NOTE: Auto-discovered by router.ts, exports default Express router
 */

import express from 'express';
import { errorClass } from '@voilajsx/appkit/error';
import { loggerClass } from '@voilajsx/appkit/logger';
import { {{featureName}}Service } from './{{featureName}}.service.js';

const router = express.Router();
const error = errorClass.get();
const logger = loggerClass.get('{{featureName}}-routes');

// GET /api/{{featureName}} - Basic {{featureName}} endpoint
router.get('/', error.asyncRoute(async (_req, res) => {
  logger.info('GET /api/{{featureName}} request received');
  const result = await {{featureName}}Service.getAll();
  res.json(result);
}));

// GET /api/{{featureName}}/:id - Get specific {{featureName}} by ID
router.get('/:id', error.asyncRoute(async (req, res) => {
  const id = req.params.id;
  logger.info('GET /api/{{featureName}}/:id request received', { id });

  const result = await {{featureName}}Service.getById(id);
  res.json(result);
}));

export default router;