async function handler(req, res) {
  try {
    if (req.session) {
      req.session.destroy((err) => {
        if (err) {
          console.error("[Logout] Session destroy error:", err);
        }
      });
    }
    res.json({
      success: true,
      message: "Logged out successfully"
    });
  } catch (error) {
    console.error("[Logout] Error:", error);
    res.status(500).json({
      success: false,
      error: "Logout failed",
      message: error instanceof Error ? error.message : "Unknown error"
    });
  }
}

export { handler as h };
