( req: ApiRequestProps<UpdateHttpToolsBodyType> )
| 17 | } from '@fastgpt/global/openapi/core/app/httpTools/api'; |
| 18 | |
| 19 | async 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 | |
| 72 | export default NextAPI(handler); |
nothing calls this directly
no test coverage detected