From 66f74642adfed0b5bbaa4fe1d59b7e4766e3efcc Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 3 Jul 2025 23:20:20 +0700 Subject: [PATCH] :pencil: create docs for logout controllers --- .../auth/controller/logout.controller.ts | 29 +++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/src/modules/auth/controller/logout.controller.ts b/src/modules/auth/controller/logout.controller.ts index 9f9c33c..f03768e 100644 --- a/src/modules/auth/controller/logout.controller.ts +++ b/src/modules/auth/controller/logout.controller.ts @@ -9,6 +9,35 @@ import { } from "../../../helpers/callback/httpResponse"; import { logoutService } from "../services/logout.service"; +/** + * @function logoutController + * @description Handles user logout by clearing authentication token from cookies. + * Requires valid active session (auth token in cookies). + * In development environment, returns additional session clearing details. + * + * @param {Context} ctx - The context object containing request information. + * + * @returns {Promise} A response object indicating logout success or failure. + * @throws {Object} An error response if no active session found or server error occurs. + * + * @example + * Request route: POST /logout + * Request headers: + * { + * "Cookie": "auth_token=" + * } + * + * Success Response: + * Status: 200 OK + * { + * "message": "Successfully logged out", + * "data": { ...clearSessionDetails } // Only in development environment + * } + * + * Failure Responses: + * - 401 Unauthorized: No active session found (not logged in) + * - 500 Internal Server Error: Server error during logout process + */ export const logoutController = async (ctx: Context) => { try { // Get the user cookie from the request, if not found, return an error