const express = require('express');
const { body } = require('express-validator');
const authController = require('../controllers/authController');
const { authenticateUser } = require('../middleware/auth');

const router = express.Router();

/**
 * Authentication Routes
 */

/**
 * @route   POST /api/v1/auth/wechat-login
 * @desc    WeChat login
 * @access  Public
 */
router.post(
  '/wechat-login',
  [
    body('code').notEmpty().withMessage('WeChat code is required'),
  ],
  authController.wechatLogin
);

/**
 * @route   POST /api/v1/auth/refresh-token
 * @desc    Refresh access token
 * @access  Public
 */
router.post(
  '/refresh-token',
  [
    body('refreshToken').notEmpty().withMessage('Refresh token is required'),
  ],
  authController.refreshToken
);

/**
 * @route   POST /api/v1/auth/logout
 * @desc    Logout user
 * @access  Private
 */
router.post('/logout', authenticateUser, authController.logout);

module.exports = router;
