/* global defineEventHandler, getCookie */ import { defineEventHandler, getCookie } from "h3"; import { database, type data } from "~/server/utils/database"; import { type user } from "~/utils/types/database"; export default defineEventHandler(async (e) => { const token = getCookie(e, "token"); const [[userData]] = await database.query( "SELECT CONVERT(`users`.`id`, CHAR(32)) as `id`, `users`.`username` as `username`, `users`.`email` as `email`, `users`.`display_name` as `display_name` FROM `sessions` LEFT JOIN `users` ON `sessions`.`user` = `users`.`id` WHERE `sessions`.`id` = ?", [token], ) as unknown as data; return userData; });