mirror of
https://github.com/hpware/news-analyze.git
synced 2025-06-23 15:51:01 +08:00
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:
parent
1e4e13f1b7
commit
d28967d3ae
@ -112,6 +112,7 @@ const submitChangeAction = async (action: string) => {
|
||||
body: JSON.stringify({
|
||||
action: actionMatch.name,
|
||||
value: actionMatch.sendValue,
|
||||
jsonValue: "",
|
||||
}),
|
||||
});
|
||||
|
||||
|
@ -24,6 +24,30 @@ export default defineEventHandler(async (event) => {
|
||||
if (body.value.match()) {
|
||||
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 {
|
||||
body: body,
|
||||
allowed: allowed,
|
||||
|
Loading…
x
Reference in New Issue
Block a user