forked from Wroclaw/WorkshopTasker
15 lines
604 B
TypeScript
15 lines
604 B
TypeScript
|
/* global defineEventHandler, getCookie */
|
||
|
|
||
|
import { database, data } from "~/server/utils/database";
|
||
|
import { 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<user>;
|
||
|
|
||
|
return userData;
|
||
|
});
|