text: "use strict";
  var __importDefault = (this && this.__importDefault) || function (mod) {
      return (mod && mod.__esModule) ? mod : { "default": mod };
  };
  Object.defineProperty(exports, "__esModule", { value: true });
  exports.AuthRoutes = void 0;
  const express_validator_1 = require("express-validator");
  const common_1 = require("./common");
  const auth_1 = __importDefault(require("../controllers/auth"));
  const users_1 = __importDefault(require("../controllers/users"));
  const auth_2 = __importDefault(require("../middleware/auth"));
  const jwt_1 = __importDefault(require("../middleware/jwt"));
  const body_validation_1 = __importDefault(require("../middleware/body.validation"));
  /**
   * The AuthRoutes class that extends the abstract class CommonRoutesConfig
   *
   * @remarks
   * Contains the configureRoutes function to configure the routes for /login and /me
   */
  class AuthRoutes extends common_1.CommonRoutesConfig {
      /**
       * The constructor for the AuthRoutes class
       *
       * @param app - application
       */
      constructor(app) {
          super(app, 'AuthRoutes');
      }
      /**
       * The configureRoutes function
       *
       * @remarks
       * Contains the routes for /login and /me
       */
      configureRoutes() {
          /**
           * The /login post method
           *
           * @remarks
           * Calls the verifyBodyFieldsErrors, verifyUserPassword and createJWT functions
           *
           * @param url - url field
           * @param body - express validated body field
           */
          this.app.post(`/login`, [
              (0, express_validator_1.body)('username').not().isEmpty(),
              (0, express_validator_1.body)('password')
                  .isLength({ min: 6 })
                  .withMessage('Must include password (6+ characters)'),
              body_validation_1.default.verifyBodyFieldsErrors,
              auth_2.default.verifyUserPassword,
              auth_1.default.createJWT,
          ]);
          /**
           * The /me post method
           *
           * @remarks
           * Calls the validJWTNeeded, checkUser and getUsername functions
           *
           * @param url - url field
           * @param body - express validated body field
           */
          this.app.post(`/me`, [
              jwt_1.default.validJWTNeeded,
              auth_2.default.checkUser,
              users_1.default.getUsername,
          ]);
          return this.app;
      }
  }
  exports.AuthRoutes = AuthRoutes;
  //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiYXV0aC5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy9yb3V0ZX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