text: const express = require('express');
  const auth = require('../../middlewares/auth');
  const validate = require('../../middlewares/validate');
  const { getDataFromToken } = require('../../middlewares/tokenGuest');
  const modelValidation = require('../../validations/model.validation');
  const moduliValidation = require('../../validations/moduli.validation');
  const modelController = require('../../controllers/model.controller');
  const moduliCtrl = require('../../controllers/moduli.controller');
  const { Modulo, QuestionModuli } = require('../../models');
  
  const modelCtrl = modelController(Modulo);
  const modelQuestionCtrl = modelController(QuestionModuli);
  
  const router = express.Router();
  
  router
      .route('/question')
      .post(auth('admin'), validate(modelValidation.create), modelQuestionCtrl.create)
      .get(auth('manager'), validate(moduliValidation.getItems), moduliCtrl.getQuestionsModuli);
  
  router
      .route('/')
      .post(auth('admin'), validate(modelValidation.create), modelCtrl.create)
      .get(auth('manager'), validate(modelValidation.getItems), modelCtrl.getItems);
  
  router
      .route('/:id')
      .get(auth('manager'), validate(modelValidation.getItem), modelCtrl.getItem)
      .patch(auth('admin',), validate(modelValidation.update), modelCtrl.update)
      .delete(auth('admin'), validate(modelValidation.delete), modelCtrl.delete);
  
  
  router
      .route('/question/:id')
      .get(auth('admin'), validate(modelValidation.getItem), modelQuestionCtrl.getItem)
      .patch(auth('admin',), validate(modelValidation.update), modelQuestionCtrl.update)
      .delete(auth('admin'), validate(modelValidation.delete), modelQuestionCtrl.delete);
  
  router
      .route('/token/:token')
      .get(validate(moduliValidation.getItemToken), moduliCtrl.getModuloGuest);
  // .patch(auth(), validate(), pathcModuloGuest);
  
  
  module.exports = router;
  
  /**
   * @swagger
   * tags:
   *   name: Moduli
   *   description: Moduli management and retrieval
   */
  
  /**
   * @swagger
   * /moduli:
   *   post:
   *     summary: Create a Modulo
   *     description: Only admins can create other Moduli.
   *     tags: [Moduli]
   *     security:
   *       - bearerAuth: []
   *     requestBody:
   *       required: true
   *       content:
   *         application/json:
   *           schema:
   *             type: object
   *             required:
   *               - title
   *             properties:
   *               title:
   *                 type: string
   *             example:
   *               title: fake name
   *     responses:
   *       "201":
   *         description: Created
   *         content:
   *           application/json:
   *             schema:
   *                $ref: '#/components/schemas/Modulo'
   *       "400":
   *         $ref: '#/components/responses/DuplicateEmail'
   *       "401":
   *         $ref: '#/components/responses/Unauthorized'
   *       "403":
   *         $ref: '#/components/responses/Forbidden'
   *
   *   get:
   *     summary: Get all Moduli
   *     description: Only admins can retrieve all Moduli.
   *     tags: [Moduli]
   *     security:
   *       - bearerAuth: []
   *     parameters:
   *       - in: query
   *         name: sortBy
   *         schema:
   *           type: string
   *         description: sort by query in the form of field:desc/asc (ex. name:asc)
   *       - in: query
   *         name: limit
   *         schema:
   *           type: integer
   *           minimum: 1
   *         default: 10
   *         description: Maximum number of users
   *       - in: query
   *         name: page
   *         schema:
   *           type: integer
   *           minimum: 1
   *           default: 1
   *         description: Page number
   *     responses:
   *       "200":
   *         description: OK
   *         content:
   *           application/json:
   *             schema:
   *               type: object
   *               properties:
   *                 results:
   *                   type: array
   *                   items:
   *                     $ref: '#/components/schemas/Modulo'
   *                 page:
   *                   type: integer
   *                   example: 1
   *                 limit:
   *                   type: integer
   *                   example: 10
   *                 totalPages:
   *                   type: integer
   *                   example: 1
   *                 totalResults:
   *                   type: integer
   *                   example: 1
   *       "401":
   *         $ref: '#/components/responses/Unauthorized'
   *       "403":
   *         $ref: '#/components/responses/Forbidden'
   */
  
  /**
   * @swagger
   * /moduli/{id}:
   *   get:
   *     summary: Get a modulo
   *     description: Logged in users can fetch only their own user information. Only admins can fetch other users.
   *     tags: [Moduli]
   *     security:
   *       - bearerAuth: []
   *     parameters:
   *       - in: path
   *         name: id
   *         required: true
   *         schema:
   *           type: string
   *         description: User id
   *     responses:
   *       "200":
   *         description: OK
   *         content:
   *           application/json:
   *             schema:
   *                $ref: '#/components/schemas/Modulo'
   *       "401":
   *         $ref: '#/components/responses/Unauthorized'
   *       "403":
   *         $ref: '#/components/responses/Forbidden'
   *       "404":
   *         $ref: '#/components/responses/NotFound'
   *
   *   patch:
   *     summary: Update a Modulo
   *     description: Logged in users can only update their own information. Only admins can update other users.
   *     tags: [Moduli]
   *     security:
   *       - bearerAuth: []
   *     parameters:
   *       - in: path
   *         name: id
   *         required: true
   *         schema:
   *           type: string
   *         description: modulo id
   *     requestBody:
   *       required: true
   *       content:
   *         application/json:
   *           schema:
   *             type: object
   *             properties:
   *               title:
   *                 type: string
   *             example:
   *               title: fake name
   *     responses:
   *       "200":
   *         description: OK
   *         content:
   *           application/json:
   *             schema:
   *                $ref: '#/components/schemas/Modulo'
   *       "400":
   *         $ref: '#/components/responses/DuplicateEmail'
   *       "401":
   *         $ref: '#/components/responses/Unauthorized'
   *       "403":
   *         $ref: '#/components/responses/Forbidden'
   *       "404":
   *         $ref: '#/components/responses/NotFound'
   *
   *   delete:
   *     summary: Delete a Modulo
   *     description: Logged in users can delete only themselves. Only admins can delete other users.
   *     tags: [Moduli]
   *     security:
   *       - bearerAuth: []
   *     parameters:
   *       - in: path
   *         name: id
   *         required: true
   *         schema:
   *           type: string
   *         description: Modulo id
   *     responses:
   *       "200":
   *         description: No content
   *       "401":
   *         $ref: '#/components/responses/Unauthorized'
   *       "403":
   *         $ref: '#/components/responses/Forbidden'
   *       "404":
   *         $ref: '#/components/responses/NotFound'
   */
  
  /**
   * @swagger
   * tags:
   *   name: questionModuli
   *   description: Moduli management and retrieval
   */
  
  /**
   * @swagger
   * /moduli/question:
   *   post:
   *     summary: Create a question Moduli
   *     description: Only admins can create other Moduli.
   *     tags: [questionModuli]
   *     security:
   *       - bearerAuth: []
   *     requestBody:
   *       required: true
   *       content:
   *         application/json:
   *           schema:
   *             type: object
   *             required:
   *               - title
   *             properties:
   *               title:
   *                 type: string
   *             example:
   *               title: fake name
   *               isPublic: true
   *               moduli: ["aaa", "bb"]
   *
   *     responses:
   *       "201":
   *         description: Created
   *         content:
   *           application/json:
   *             schema:
   *                $ref: '#/components/schemas/Modulo'
   *       "400":
   *         $ref: '#/components/responses/DuplicateEmail'
   *       "401":
   *         $ref: '#/components/responses/Unauthorized'
   *       "403":
   *         $ref: '#/components/responses/Forbidden'
   *
   *   get:
   *     summary: Get all Moduli
   *     description: Only admins can retrieve all Moduli.
   *     tags: [questionModuli]
   *     security:
   *       - bearerAuth: []
   *     parameters:
   *       - in: query
   *         name: isPublic
   *         schema:
   *           type: boolean
   *           default: false
   *         description: filter Public
   *       - in: query
   *         name: sortBy
   *         schema:
   *           type: string
   *         description: sort by query in the form of field:desc/asc (ex. name:asc)
   *       - in: query
   *         name: limit
   *         schema:
   *           type: integer
   *           minimum: 1
   *         default: 10
   *         description: Maximum number of users
   *       - in: query
   *         name: page
   *         schema:
   *           type: integer
   *           minimum: 1
   *           default: 1
   *         description: Page number
   *     responses:
   *       "200":
   *         description: OK
   *         content:
   *           application/json:
   *             schema:
   *               type: object
   *               properties:
   *                 results:
   *                   type: array
   *                   items:
   *                     $ref: '#/components/schemas/Modulo'
   *                 page:
   *                   type: integer
   *                   example: 1
   *                 limit:
   *                   type: integer
   *                   example: 10
   *                 totalPages:
   *                   type: integer
   *                   example: 1
   *                 totalResults:
   *                   type: integer
   *                   example: 1
   *       "401":
   *         $ref: '#/components/responses/Unauthorized'
   *       "403":
   *         $ref: '#/components/responses/Forbidden'
   */
  
  /**
   * @swagger
   * /moduli/question/{id}:
   *   get:
   *     summary: Get a modulo
   *     description: Logged in users can fetch only their own user information. Only admins can fetch other users.
   *     tags: [questionModuli]
   *     security:
   *       - bearerAuth: []
   *     parameters:
   *       - in: path
   *         name: id
   *         required: true
   *         schema:
   *           type: string
   *         description: User id
   *     responses:
   *       "200":
   *         description: OK
   *         content:
   *           application/json:
   *             schema:
   *                $ref: '#/components/schemas/Modulo'
   *       "401":
   *         $ref: '#/components/responses/Unauthorized'
   *       "403":
   *         $ref: '#/components/responses/Forbidden'
   *       "404":
   *         $ref: '#/components/responses/NotFound'
   *
   *   patch:
   *     summary: Update a Modulo
   *     description: Logged in users can only update their own information. Only admins can update other users.
   *     tags: [questionModuli]
   *     security:
   *       - bearerAuth: []
   *     parameters:
   *       - in: path
   *         name: id
   *         required: true
   *         schema:
   *           type: string
   *         description: modulo id
   *     requestBody:
   *       required: true
   *       content:
   *         application/json:
   *           schema:
   *             type: object
   *             properties:
   *               title:
   *                 type: string
   *             example:
   *               title: fake name
   *     responses:
   *       "200":
   *         description: OK
   *         content:
   *           application/json:
   *             schema:
   *                $ref: '#/components/schemas/Modulo'
   *       "400":
   *         $ref: '#/components/responses/DuplicateEmail'
   *       "401":
   *         $ref: '#/components/responses/Unauthorized'
   *       "403":
   *         $ref: '#/components/responses/Forbidden'
   *       "404":
   *         $ref: '#/components/responses/NotFound'
   *
   *   delete:
   *     summary: Delete a Modulo
   *     description: Logged in users can delete only themselves. Only admins can delete other users.
   *     tags: [questionModuli]
   *     security:
   *       - bearerAuth: []
   *     parameters:
   *       - in: path
   *         name: id
   *         required: true
   *         schema:
   *           type: string
   *         description: Modulo id
   *     responses:
   *       "200":
   *         description: No content
   *       "401":
   *         $ref: '#/components/responses/Unauthorized'
   *       "403":
   *         $ref: '#/components/responses/Forbidden'
   *       "404":
   *         $ref: '#/components/responses/NotFound'
   */
  
  /**
   * @swagger
   * /moduli/token/{token}:
   *   get:
   *     summary: Get a modulo by token
   *     description: user with guest token data retrieve.
   *     tags: [Moduli]
   *     parameters:
   *       - in: path
   *         name: token
   *         required: true
   *         schema:
   *           type: string
   *         description: Guest User token
   *     responses:
   *       "200":
   *         description: OK
   *         content:
   *           application/json:
   *             schema:
   *                $ref: '#/components/schemas/Modulo'
   *       "401":
   *         $ref: '#/components/responses/Unauthorized'
   *       "403":
   *         $ref: '#/components/responses/Forbidden'
   *       "404":
   *         $ref: '#/components/responses/NotFound'
   *
   *   patch:
   *     summary: Update a Modulo
   *     description: Guest users with token can only update their own information.
   *     tags: [Moduli]
   *     parameters:
   *       - in: path
   *         name: token
   *         required: true
   *         schema:
   *           type: string
   *         description: modulo id
   *     requestBody:
   *       required: true
   *       content:
   *         application/json:
   *           schema:
   *             type: object
   *             properties:
   *               title:
   *                 type: string
   *             example:
   *               title: fake name
   *     responses:
   *       "200":
   *         description: OK
   *         content:
   *           application/json:
   *             schema:
   *                $ref: '#/components/schemas/Modulo'
   *       "400":
   *         $ref: '#/components/responses/DuplicateEmail'
   *       "401":
   *         $ref: '#/components/responses/Unauthorized'
   *       "403":
   *         $ref: '#/components/responses/Forbidden'
   *       "404":
   *         $ref: '#/components/responses/NotFound'
   */
  