MCPcopy
hub / github.com/FlowiseAI/Flowise / updateApiKey

Function updateApiKey

packages/server/src/services/apikey/index.ts:194–210  ·  view source on GitHub ↗
(user: LoggedInUser, id: string, keyName: string, permissions: string[])

Source from the content-addressed store, hash-verified

192
193// Update api key
194const updateApiKey = async (user: LoggedInUser, id: string, keyName: string, permissions: string[]) => {
195 // Validate permissions before updating the key
196 validatePermissions(user, permissions, 'update')
197
198 const appServer = getRunningExpressApp()
199 const currentKey = await appServer.AppDataSource.getRepository(ApiKey).findOneBy({
200 id: id,
201 workspaceId: user.activeWorkspaceId
202 })
203 if (!currentKey) {
204 throw new InternalFlowiseError(StatusCodes.NOT_FOUND, `ApiKey ${currentKey} not found`)
205 }
206 currentKey.keyName = keyName
207 currentKey.permissions = permissions
208 await appServer.AppDataSource.getRepository(ApiKey).save(currentKey)
209 return await getAllApiKeys(user)
210}
211
212const deleteApiKey = async (id: string, workspaceId: string) => {
213 try {

Callers

nothing calls this directly

Calls 3

getRunningExpressAppFunction · 0.90
validatePermissionsFunction · 0.85
getAllApiKeysFunction · 0.70

Tested by

no test coverage detected