# Code coverage report for api/routers/userRoutes.js

# All files / api/routers userRoutes.js

0% Statements 0/16
100% Branches 0/0
0% Functions 0/6
0% Lines 0/11

Press n or j to go to the next uncovered block, b, p or k for the previous block.

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50

     const express = require('express');
    const authMiddleware = require('../middlewares/authMiddleware');

    /**
     * User Routes
     * Protected endpoints (JWT authentication required)
     *
     * @param {Container} container - DI Container
     */
    function createUserRoutes(container) {
      const router = express.Router();

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

      /**
       * GET /api/users/me - Bejelentkezett user adatai
       * Headers: Authorization: Bearer <token>
       */
      router.get('/me', authMiddleware, (req, res) => userController.getMe(req, res));

      /**
       * PUT /api/users/me - User profil frissítése
       * Headers: Authorization: Bearer <token>
       * Body: { name }
       */
      router.put('/me', authMiddleware, (req, res) => userController.updateMe(req, res));

      /**
       * GET /api/users - Összes user lekérése (protected)
       * Headers: Authorization: Bearer <token>
       */
      router.get('/', authMiddleware, (req, res) => userController.getAll(req, res));

      /**
       * GET /api/users/:id - User lekérése ID alapján (protected)
       * Headers: Authorization: Bearer <token>
       */
      router.get('/:id', authMiddleware, (req, res) => userController.getById(req, res));

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

      return router;
    }

    module.exports = createUserRoutes;