📝 create docs for logout controllers

This commit is contained in:
unknown
2025-07-03 23:20:20 +07:00
parent 6a4cc1b2d7
commit 66f74642ad

View File

@ -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<Object>} 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=<JWT_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