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

Function handler

projects/app/src/pages/api/core/app/httpTools/update.ts:19–70  ·  view source on GitHub ↗
(
  req: ApiRequestProps<UpdateHttpToolsBodyType>
)

Source from the content-addressed store, hash-verified

17} from '@fastgpt/global/openapi/core/app/httpTools/api';
18
19async function handler(
20 req: ApiRequestProps<UpdateHttpToolsBodyType>
21): Promise<UpdateHttpToolsResponseType> {
22 const { appId, baseUrl, apiSchemaStr, toolList, headerSecret, customHeaders } = parseApiInput({
23 req,
24 bodySchema: UpdateHttpToolsBodySchema
25 }).body;
26
27 const { app } = await authApp({ req, authToken: true, appId, per: ManagePermissionVal });
28
29 const formatedHeaderAuth = storeSecretValue(headerSecret);
30
31 const formattedToolList = toolList.map((tool) => ({
32 ...tool,
33 headerSecret: tool.headerSecret ? storeSecretValue(tool.headerSecret) : undefined
34 }));
35
36 const toolSetRuntimeNode = getHTTPToolSetRuntimeNode({
37 name: app.name,
38 avatar: app.avatar,
39 baseUrl,
40 apiSchemaStr,
41 toolList: formattedToolList,
42 headerSecret: formatedHeaderAuth,
43 customHeaders
44 });
45
46 await mongoSessionRun(async (session) => {
47 await MongoApp.findByIdAndUpdate(
48 appId,
49 {
50 modules: [toolSetRuntimeNode]
51 },
52 { session }
53 );
54
55 await MongoAppVersion.updateOne(
56 { appId },
57 {
58 $set: {
59 nodes: [toolSetRuntimeNode]
60 }
61 },
62 { session }
63 );
64 });
65 updateParentFoldersUpdateTime({
66 parentId: app.parentId
67 });
68
69 return UpdateHttpToolsResponseSchema.parse(undefined);
70}
71
72export default NextAPI(handler);

Callers

nothing calls this directly

Calls 8

parseApiInputFunction · 0.90
authAppFunction · 0.90
storeSecretValueFunction · 0.90
mongoSessionRunFunction · 0.90
mapMethod · 0.45
parseMethod · 0.45

Tested by

no test coverage detected