const express = require('express');

/**
 * Auth Routes
 * Public endpoints (nincs JWT védelem)
 * 
 * @param {Container} container - DI Container
 */
function createAuthRoutes(container) {
  const router = express.Router();

  // AuthController lekérése a DI Container-ből
  const authController = container.resolve('AuthController');

  /**
   * POST /api/auth/register - User regisztráció
   * Body: { name, email, password }
   * Response: { user, token }
   */
  router.post('/register', (req, res) => authController.register(req, res));

  /**
   * POST /api/auth/login - User bejelentkezés
   * Body: { email, password }
   * Response: { user, token }
   */
  router.post('/login', (req, res) => authController.login(req, res));

  /**
   * POST /api/auth/logout - User kijelentkezés
   * Clears the authentication cookie
   */
  router.post('/logout', (req, res) => authController.logout(req, res));

  /**
   * OPTIONS /api/auth/* - CORS preflight
   */
  router.options('*', (req, res) => res.sendStatus(204));

  return router;
}

module.exports = createAuthRoutes;
