HEX
Server: Apache/2.4.52 (Ubuntu)
System: Linux spn-python 5.15.0-89-generic #99-Ubuntu SMP Mon Oct 30 20:42:41 UTC 2023 x86_64
User: arjun (1000)
PHP: 8.1.2-1ubuntu2.20
Disabled: NONE
Upload Files
File: //home/arjun/projects/good-life-be/api/Auth/index.js
import express from 'express';
import {
  emailVerification,
  resetPassword,
  sendForgotPasswordEmail,
  signIn,
  signUp,
} from './controller.js';
import {
  loginValidator,
  resetPasswordValidator,
  signupValidator,
} from './validator.js';

const router = express.Router();

router.post('/signin', loginValidator, signIn);
/**
 * @swagger
 * /api/auth/signin:
 *   post:
 *     summary: Login
 *     tags:
 *       - Auth
 *     requestBody:
 *       content:
 *         application/json:
 *           schema:
 *             type: object
 *             properties:
 *               email:
 *                 type: string
 *                 example: "admin@spericorn.com"
 *               password:
 *                 type: string
 *                 example: "admin@123"
 *     responses:
 *       200:
 *         description: Success. Login successfully.
 *       400:
 *         description: Bad request. Invalid parameters or missing data.
 *       500:
 *         description: Internal server error.
 */

router.post('/signup', signupValidator, signUp);
/**
 * @swagger
 * /api/auth/signup:
 *   post:
 *     summary: Sign up a new user
 *     tags:
 *       - Auth
 *     requestBody:
 *       required: true
 *       content:
 *         application/json:
 *           schema:
 *             type: object
 *             properties:
 *               email:
 *                 type: string
 *                 example: jane.doe@example.com
 *               password:
 *                 type: string
 *                 example: securepassword
 *               firstName:
 *                 type: string
 *                 example: Jane
 *               secondName:
 *                 type: string
 *                 example: Doe
 *     responses:
 *       201:
 *         description: User successfully signed up
 *         content:
 *           application/json:
 *             schema:
 *               type: object
 *               properties:
 *                 message:
 *                   type: string
 *                   example: Sign-up successful.
 *                 user:
 *                   type: object
 *                   properties:
 *                     id:
 *                       type: string
 *                       format: uuid
 *                       example: a12345b6-78cd-90ef-12gh-34567ijklmno
 *                     first_name:
 *                       type: string
 *                       example: Jane
 *                     second_name:
 *                       type: string
 *                       example: Doe
 *                     email:
 *                       type: string
 *                       example: jane.doe@example.com
 *       400:
 *         description: Missing or invalid input fields
 *       409:
 *         description: Email is already registered
 *       500:
 *         description: Internal server error
 */

router.get('/verify-email', emailVerification);
/**
 * @swagger
 * /api/auth/verify-email:
 *   get:
 *     tags:
 *       - Auth
 *     summary: Verifies the user's email address using the verification token
 *     description: This endpoint allows the user to verify their email address by clicking the link sent to their email.
 *     parameters:
 *       - in: query
 *         name: token
 *         required: true
 *         description: The verification token sent to the user's email address
 *     responses:
 *       200:
 *         description: Successfully verified the email.
 *       400:
 *         description: Invalid or expired verification token.
 *       404:
 *         description: User not found or token does not match.
 */

router.post('/forgot-password', sendForgotPasswordEmail);
/**
 * @swagger
 * /api/auth/forgot-password:
 *   post:
 *     summary: User
 *     tags:
 *       - Auth
 *     requestBody:
 *       content:
 *         application/json:
 *           schema:
 *             type: object
 *             properties:
 *               email:
 *                 type: string
 *                 example: "admin@spericorn.com"
 *     responses:
 *       200:
 *         description: Success. Reset link has been sent successfully.
 *       400:
 *         description: Bad request. Invalid parameters or missing data.
 *       404:
 *         description: Not found. User not found.
 *       500:
 *         description: Internal server error.
 */

router.post('/reset-password', resetPassword);
/**
 * @swagger
 * /api/auth/reset-password:
 *   post:
 *     summary: User
 *     tags:
 *       - Auth
 *     requestBody:
 *       content:
 *         application/json:
 *           schema:
 *             type: object
 *             properties:
 *               token:
 *                 type: string
 *               password:
 *                 type: string
 *     responses:
 *       200:
 *         description: Success. Reset link has been sent successfully.
 *       400:
 *         description: Bad request. Invalid parameters or missing data.
 *       404:
 *         description: Not found. User not found.
 *       500:
 *         description: Internal server error.
 */

export default router;