chore: upgrade mongoose to v8.10.x for security (#3868)

* chore: upgrade mongoose to v8.10.x for security

* chore: remove duplicate code

* fix: ts error
This commit is contained in:
Finley Ge
2025-02-26 18:32:19 +08:00
committed by GitHub
parent cf9c8e9f6a
commit 747bb303ec
7 changed files with 54 additions and 13 deletions

View File

@@ -178,7 +178,7 @@ export const getClbsAndGroupsWithInfo = async ({
]);
export const delResourcePermissionById = (id: string) => {
return MongoResourcePermission.findByIdAndRemove(id);
return MongoResourcePermission.findByIdAndDelete(id);
};
export const delResourcePermission = ({
session,

View File

@@ -1,5 +1,5 @@
import { AppDetailType } from '@fastgpt/global/core/app/type';
import { OutlinkAppType, OutLinkSchema } from '@fastgpt/global/support/outLink/type';
import { OutLinkSchema } from '@fastgpt/global/support/outLink/type';
import { parseHeaderCert } from '../controller';
import { MongoOutLink } from '../../outLink/schema';
import { OutLinkErrEnum } from '@fastgpt/global/common/error/code/outLink';
@@ -54,15 +54,11 @@ export async function authOutLinkCrud({
}
/* outLink exist and it app exist */
export async function authOutLinkValid<T extends OutlinkAppType = undefined>({
shareId
}: {
shareId?: string;
}) {
export async function authOutLinkValid({ shareId }: { shareId?: string }) {
if (!shareId) {
return Promise.reject(OutLinkErrEnum.linkUnInvalid);
}
const outLinkConfig = (await MongoOutLink.findOne({ shareId }).lean()) as OutLinkSchema<T>;
const outLinkConfig = await MongoOutLink.findOne({ shareId }).lean();
if (!outLinkConfig) {
return Promise.reject(OutLinkErrEnum.linkUnInvalid);

View File

@@ -64,7 +64,7 @@ export const checkTeamDatasetLimit = async (teamId: string) => {
export const checkTeamAppLimit = async (teamId: string, amount = 1) => {
const [{ standardConstants }, appCount] = await Promise.all([
getTeamStandPlan({ teamId }),
MongoApp.count({
MongoApp.countDocuments({
teamId,
type: { $in: [AppTypeEnum.simple, AppTypeEnum.workflow, AppTypeEnum.plugin] }
})