mirror of
https://github.com/hpware/news-analyze.git
synced 2025-06-23 15:51:01 +08:00
24 lines
581 B
TypeScript
24 lines
581 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",
|
|
};
|
|
}
|
|
if (request_change === "groq_api_key") {
|
|
const updateListing = await sql``;
|
|
}
|
|
});
|