mirror of
https://github.com/labring/FastGPT.git
synced 2025-07-30 18:48:55 +00:00
27 lines
692 B
TypeScript
27 lines
692 B
TypeScript
import type { NextApiRequest, NextApiResponse } from 'next';
|
|
import type { HttpBodyType } from '@fastgpt/global/core/module/api.d';
|
|
import { getErrText } from '@fastgpt/global/common/error/utils';
|
|
import { replaceVariable } from '@fastgpt/global/common/string/tools';
|
|
|
|
type Props = HttpBodyType<{
|
|
text: string;
|
|
[key: string]: any;
|
|
}>;
|
|
|
|
export default async function handler(req: NextApiRequest, res: NextApiResponse<any>) {
|
|
try {
|
|
const {
|
|
data: { text, ...obj }
|
|
} = req.body as Props;
|
|
|
|
const textResult = replaceVariable(text, obj);
|
|
|
|
res.json({
|
|
text: textResult
|
|
});
|
|
} catch (err) {
|
|
console.log(err);
|
|
res.status(500).send(getErrText(err));
|
|
}
|
|
}
|