Add bascic groq api key saving function (but I can't test it, as my

laptop is basic unusable when launching the dev server, So I guess I'm
testing in prod now 🤷🤷🤷🤷
This commit is contained in:
吳元皓 2025-06-09 10:46:34 +08:00
parent 1e4e13f1b7
commit d28967d3ae
2 changed files with 25 additions and 0 deletions

View File

@ -112,6 +112,7 @@ const submitChangeAction = async (action: string) => {
body: JSON.stringify({ body: JSON.stringify({
action: actionMatch.name, action: actionMatch.name,
value: actionMatch.sendValue, value: actionMatch.sendValue,
jsonValue: "",
}), }),
}); });

View File

@ -24,6 +24,30 @@ export default defineEventHandler(async (event) => {
if (body.value.match()) { if (body.value.match()) {
allowed = false; allowed = false;
} }
// Use Static values for now.
const requestChange = "groq_api_key";
const apiKeyqq = body.value.match(clearBadDataRegex);
const allowedColumns = ["groq_api_key", "another_column_name"];
if (!allowedColumns.includes(requestChange)) {
throw new Error("Invalid column name provided");
}
const sqlC = await sql.unsafe`
UPDATE user_other_data SET ${requestChange} = ${apiKeyqq[0]}
WHERE username = ${checkUserToken[0].username}`;
/**
* // Example of how requestChange might be validated
const allowedColumns = ['groq_api_key', 'another_column_name'];
if (!allowedColumns.includes(requestChange)) {
throw new Error('Invalid column name provided');
}
const sqlC = await sql`
UPDATE user_other_data SET ${sql.identifier([requestChange])} = ${apiKeyqq[0]}
WHERE username = ${checkUserToken[0].username}`;
*/
return { return {
body: body, body: body,
allowed: allowed, allowed: allowed,