MCPcopy
hub / github.com/labring/FastGPT / handler

Function handler

projects/app/src/pages/api/core/dataset/folder/create.ts:26–81  ·  view source on GitHub ↗
(req: ApiRequestProps<CreateDatasetFolderBody>)

Source from the content-addressed store, hash-verified

24} from '@fastgpt/global/openapi/core/dataset/api';
25
26async function handler(req: ApiRequestProps<CreateDatasetFolderBody>) {
27 const { parentId, name, intro } = parseApiInput({
28 req,
29 bodySchema: CreateDatasetFolderBodySchema
30 }).body;
31
32 const { teamId, tmbId } = parentId
33 ? await authDataset({
34 req,
35 datasetId: parentId,
36 authToken: true,
37 authApiKey: true,
38 per: WritePermissionVal
39 })
40 : await authUserPer({
41 req,
42 authToken: true,
43 authApiKey: true,
44 per: TeamDatasetCreatePermissionVal
45 });
46
47 await checkTeamDatasetFolderLimit({ teamId });
48
49 await checkCreateFolderDepth({ parentId, teamId, model: MongoDataset });
50
51 await mongoSessionRun(async (session) => {
52 const dataset = await MongoDataset.create({
53 ...parseParentIdInMongo(parentId),
54 avatar: FolderImgUrl,
55 name,
56 intro,
57 teamId,
58 tmbId,
59 type: DatasetTypeEnum.folder
60 });
61
62 await createResourceDefaultCollaborators({
63 tmbId,
64 session,
65 resource: dataset,
66 resourceType: PerResourceTypeEnum.dataset
67 });
68 });
69 (async () => {
70 addAuditLog({
71 tmbId,
72 teamId,
73 event: AuditEventEnum.CREATE_DATASET_FOLDER,
74 params: {
75 folderName: name
76 }
77 });
78 })();
79
80 return {};
81}
82export default NextAPI(handler);

Callers

nothing calls this directly

Calls 10

parseApiInputFunction · 0.90
authDatasetFunction · 0.90
authUserPerFunction · 0.90
checkCreateFolderDepthFunction · 0.90
mongoSessionRunFunction · 0.90
parseParentIdInMongoFunction · 0.90
addAuditLogFunction · 0.90
createMethod · 0.65

Tested by

no test coverage detected