first commit

This commit is contained in:
Rafi
2023-02-11 17:37:20 +08:00
commit 0c4f782a1b
22 changed files with 5949 additions and 0 deletions

19
server/api/settings.js Normal file
View File

@@ -0,0 +1,19 @@
import {getSetting, setSetting} from "~/utils/keyv";
import {apiError, apiSuccess} from "~/utils/api";
export default defineEventHandler(async (event) => {
const runtimeConfig = useRuntimeConfig()
const method = getMethod(event)
if (method === 'GET') {
const query = getQuery(event)
let value = await getSetting(query.key)
if (!value && query.key === 'modelName') {
value = runtimeConfig.openaiModelName
}
return apiSuccess(value)
} else if (method === 'POST') {
const body = await readBody(event)
await setSetting(body.key, body.value)
return apiSuccess()
}
})