import { d as defineEventHandler, g as getCookie, a as deleteCookie, c as createError } from '../../../nitro/nitro.mjs';
import { d as deleteSession } from '../../../_/auth.mjs';
import 'node:http';
import 'node:https';
import 'node:events';
import 'node:buffer';
import 'node:fs';
import 'node:path';
import 'node:crypto';
import 'node:url';
import 'bcryptjs';
import 'jsonwebtoken';
import 'fs';
import 'path';
import '../../../_/encryption.mjs';
import 'crypto';

const logout_post = defineEventHandler(async (event) => {
  try {
    const token = getCookie(event, "auth_token");
    if (token) {
      await deleteSession(token);
    }
    deleteCookie(event, "auth_token");
    return {
      success: true,
      message: "Erfolgreich abgemeldet"
    };
  } catch (error) {
    console.error("Logout-Fehler:", error);
    throw createError({
      statusCode: 500,
      message: "Abmeldung fehlgeschlagen"
    });
  }
});

export { logout_post as default };
//# sourceMappingURL=logout.post.mjs.map
