news-analyze/server/api/user/sendUserInfo.post.ts
吳元皓 3a85eda19a Update createDatabase scripts & get sendUserInfo endpoint & when
creating an account it will also create a array in user_other_data.
2025-06-07 09:21:37 +08:00

20 lines
495 B
TypeScript

import sql from "~/server/components/postgres";
export default defineEventHandler(async (event) => {
const body = await readBody(event);
const { request_change } = body;
const userToken = getCookie(event, "token");
if (!userToken) {
return {
error: "ERR_NOT_ALLOWED",
};
}
const checkUserToken = await sql`
select * from usertokens
where token=${userToken}
`;
if (checkUserToken.length === 0) {
return {
error: "ERR_NOT_ALLOWED",
};
}
});