Initial commit
This commit is contained in:
commit
1e63e008af
48 changed files with 12715 additions and 0 deletions
14
server/api/users/me.get.ts
Normal file
14
server/api/users/me.get.ts
Normal file
|
@ -0,0 +1,14 @@
|
|||
/* 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;
|
||||
});
|
Loading…
Add table
Add a link
Reference in a new issue