mirror of
https://github.com/labring/FastGPT.git
synced 2025-08-04 05:56:08 +00:00
30 lines
685 B
TypeScript
30 lines
685 B
TypeScript
import type { NextApiRequest, NextApiResponse } from 'next';
|
|
import { jsonRes } from '@/service/response';
|
|
import { connectToDatabase, OutLink } from '@/service/mongo';
|
|
import { authUser } from '@/service/utils/auth';
|
|
|
|
/* delete a shareChat by shareChatId */
|
|
export default async function handler(req: NextApiRequest, res: NextApiResponse) {
|
|
try {
|
|
await connectToDatabase();
|
|
|
|
const { id } = req.query as {
|
|
id: string;
|
|
};
|
|
|
|
const { userId } = await authUser({ req, authToken: true });
|
|
|
|
await OutLink.findOneAndRemove({
|
|
_id: id,
|
|
userId
|
|
});
|
|
|
|
jsonRes(res);
|
|
} catch (err) {
|
|
jsonRes(res, {
|
|
code: 500,
|
|
error: err
|
|
});
|
|
}
|
|
}
|