import { d as defineEventHandler, g as getCookie, a as getHeader, c as createError } from '../../../nitro/nitro.mjs';
import jwt from 'jsonwebtoken';
import 'node:http';
import 'node:https';
import 'node:events';
import 'node:buffer';
import 'node:fs';
import 'node:path';
import 'node:crypto';
import 'node:url';

const verify_get = defineEventHandler(async (event) => {
  var _a;
  try {
    const token = getCookie(event, "auth-token") || ((_a = getHeader(event, "authorization")) == null ? void 0 : _a.replace("Bearer ", ""));
    if (!token) {
      throw createError({
        statusCode: 401,
        statusMessage: "\uC778\uC99D \uD1A0\uD070\uC774 \uC5C6\uC2B5\uB2C8\uB2E4."
      });
    }
    const decoded = jwt.verify(token, "your-secret-key");
    return {
      success: true,
      user: {
        id: decoded.id,
        user_id: decoded.user_id,
        name: decoded.name,
        role_level: decoded.role_level
      }
    };
  } catch (error) {
    console.error("Token verification error:", error);
    throw createError({
      statusCode: 401,
      statusMessage: "\uC720\uD6A8\uD558\uC9C0 \uC54A\uC740 \uD1A0\uD070\uC785\uB2C8\uB2E4."
    });
  }
});

export { verify_get as default };
