mirror of
https://github.com/labring/FastGPT.git
synced 2025-08-02 12:48:30 +00:00
29 lines
838 B
TypeScript
29 lines
838 B
TypeScript
// Next.js API route support: https://nextjs.org/docs/api-routes/introduction
|
|
import type { NextApiRequest, NextApiResponse } from 'next';
|
|
import { jsonRes } from '@/service/response';
|
|
import { connectToDatabase } from '@/service/mongo';
|
|
import { MongoOpenApi } from '@fastgpt/service/support/openapi/schema';
|
|
import { authUser } from '@fastgpt/service/support/user/auth';
|
|
|
|
export default async function handler(req: NextApiRequest, res: NextApiResponse) {
|
|
try {
|
|
await connectToDatabase();
|
|
const { id } = req.query as { id: string };
|
|
|
|
if (!id) {
|
|
throw new Error('缺少参数');
|
|
}
|
|
|
|
const { userId } = await authUser({ req, authToken: true });
|
|
|
|
await MongoOpenApi.findOneAndRemove({ _id: id, userId });
|
|
|
|
jsonRes(res);
|
|
} catch (err) {
|
|
jsonRes(res, {
|
|
code: 500,
|
|
error: err
|
|
});
|
|
}
|
|
}
|