text: const express = require('express');
  const auth = require('../../middlewares/auth');
  const validate = require('../../middlewares/validate');
  const transactionValidation = require('../../validations/transaction.validation');
  const transactionController = require('../../controllers/transaction.controller');
  
  const router = express.Router();
  
  router
    .route('/')
    .post(
      auth('manageTransactions'),
      validate(transactionValidation.createTransaction),
      transactionController.createTransaction
    )
    .get(auth('getTransactions'), validate(transactionValidation.getTransactions), transactionController.getTransactions);
  
  router
    .route('/:transactionId')
    .get(auth('getTransactions'), validate(transactionValidation.getTransaction), transactionController.getTransaction)
    .patch(
      auth('manageTransactions'),
      validate(transactionValidation.updateTransaction),
      transactionController.updateTransaction
    )
    .delete(
      auth('manageTransactions'),
      validate(transactionValidation.deleteTransaction),
      transactionController.deleteTransaction
    );
  
  module.exports = router;
  
  /**
   * @swagger
   * tags:
   *   name: Transactions
   *   description: Transaction management and retrieval
   */
  
  /**
   * @swagger
   * /transactions:
   *   post:
   *     summary: Create a transaction
   *     description: Only admins can create transactions.
   *     tags: [Transactions]
   *     security:
   *       - bearerAuth: []
   *     requestBody:
   *       required: true
   *       content:
   *         application/json:
   *           schema:
   *             type: object
   *             required:
   *               - transactionName
   *               - initBalance
   *             properties:
   *               transactionName:
   *                 type: string
   *               initBalance:
   *                 type: number
   *               descr:
   *                 type: string
   *               archived:
   *                 type: boolean
   *               sortOrder:
   *                 type: number
   *             example:
   *               transactionName: My Bank
   *               initBalance: 10
   *               descr: Mu bank transaction number 234244
   *     responses:
   *       "201":
   *         description: Created
   *         content:
   *           application/json:
   *             schema:
   *                $ref: '#/components/schemas/Transaction'
   *       "400":
   *         $ref: '#/components/responses/BadRequest'
   *       "401":
   *         $ref: '#/components/responses/Unauthorized'
   *       "403":
   *         $ref: '#/components/responses/Forbidden'
   *
   *   get:
   *     summary: Get all transactions
   *     description: Only admins can retrieve all transactions.
   *     tags: [Transactions]
   *     security:
   *       - bearerAuth: []
   *     parameters:
   *       - in: query
   *         name: name
   *         schema:
   *           type: string
   *         description: Transaction name
   *       - in: query
   *         name: role
   *         schema:
   *           type: string
   *         description: Transaction role
   *       - 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 transactions
   *       - 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/Transaction'
   *                 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
   * /transactions/{id}:
   *   get:
   *     summary: Get a transaction
   *     description: Logged in transactions can fetch only their own transaction information. Only admins can fetch other transactions.
   *     tags: [Transactions]
   *     security:
   *       - bearerAuth: []
   *     parameters:
   *       - in: path
   *         name: id
   *         required: true
   *         schema:
   *           type: string
   *         description: Transaction id
   *     responses:
   *       "200":
   *         description: OK
   *         content:
   *           application/json:
   *             schema:
   *                $ref: '#/components/schemas/Transaction'
   *       "401":
   *         $ref: '#/components/responses/Unauthorized'
   *       "403":
   *         $ref: '#/components/responses/Forbidden'
   *       "404":
   *         $ref: '#/components/responses/NotFound'
   *
   *   patch:
   *     summary: Update a transaction
   *     description: Logged in transactions can only update their own information. Only admins can update other transactions.
   *     tags: [Transactions]
   *     security:
   *       - bearerAuth: []
   *     parameters:
   *       - in: path
   *         name: id
   *         required: true
   *         schema:
   *           type: string
   *         description: Transaction id
   *     requestBody:
   *       required: true
   *       content:
   *         application/json:
   *           schema:
   *             type: object
   *             properties:
   *               name:
   *                 type: string
   *               email:
   *                 type: string
   *                 format: email
   *                 description: must be unique
   *               password:
   *                 type: string
   *                 format: password
   *                 minLength: 8
   *                 description: At least one number and one letter
   *             example:
   *               name: fake name
   *               email: fake@example.com
   *               password: password1
   *     responses:
   *       "200":
   *         description: OK
   *         content:
   *           application/json:
   *             schema:
   *                $ref: '#/components/schemas/Transaction'
   *       "400":
   *         $ref: '#/components/responses/DuplicateEmail'
   *       "401":
   *         $ref: '#/components/responses/Unauthorized'
   *       "403":
   *         $ref: '#/components/responses/Forbidden'
   *       "404":
   *         $ref: '#/components/responses/NotFound'
   *
   *   delete:
   *     summary: Delete a transaction
   *     description: Logged in transactions can delete only themselves. Only admins can delete other transactions.
   *     tags: [Transactions]
   *     security:
   *       - bearerAuth: []
   *     parameters:
   *       - in: path
   *         name: id
   *         required: true
   *         schema:
   *           type: string
   *         description: Transaction id
   *     responses:
   *       "200":
   *         description: No content
   *       "401":
   *         $ref: '#/components/responses/Unauthorized'
   *       "403":
   *         $ref: '#/components/responses/Forbidden'
   *       "404":
   *         $ref: '#/components/responses/NotFound'
   */
  