mirror of
https://github.com/labring/FastGPT.git
synced 2025-08-05 22:55:27 +00:00
feat: admin set env
This commit is contained in:
32
client/src/pages/api/system/updateEnv.ts
Normal file
32
client/src/pages/api/system/updateEnv.ts
Normal file
@@ -0,0 +1,32 @@
|
||||
import type { NextApiRequest, NextApiResponse } from 'next';
|
||||
import { jsonRes } from '@/service/response';
|
||||
import { System } from '@/service/models/system';
|
||||
import { authUser } from '@/service/utils/auth';
|
||||
|
||||
export type InitDateResponse = {
|
||||
beianText: string;
|
||||
googleVerKey: string;
|
||||
};
|
||||
|
||||
export default async function handler(req: NextApiRequest, res: NextApiResponse) {
|
||||
await authUser({ req, authRoot: true });
|
||||
updateSystemEnv();
|
||||
jsonRes<InitDateResponse>(res);
|
||||
}
|
||||
|
||||
export async function updateSystemEnv() {
|
||||
try {
|
||||
const mongoData = await System.findOne();
|
||||
|
||||
if (mongoData) {
|
||||
const obj = mongoData.toObject();
|
||||
global.systemEnv = {
|
||||
...global.systemEnv,
|
||||
...obj
|
||||
};
|
||||
}
|
||||
console.log('update env', global.systemEnv);
|
||||
} catch (error) {
|
||||
console.log('update system env error');
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user