diff --git a/backend/src/integrations/apps.ts b/backend/src/integrations/apps.ts index b2fec9292..0d5a8239f 100644 --- a/backend/src/integrations/apps.ts +++ b/backend/src/integrations/apps.ts @@ -32,6 +32,8 @@ import { INTEGRATION_TRAVISCI_API_URL, INTEGRATION_VERCEL, INTEGRATION_VERCEL_API_URL, + INTEGRATION_WINDMILL, + INTEGRATION_WINDMILL_API_URL, } from "../variables"; interface App { @@ -145,6 +147,11 @@ const getApps = async ({ accountId: accessId }) break; + case INTEGRATION_WINDMILL: + apps = await getAppsWindmill({ + accessToken, + }); + break; } return apps; @@ -721,4 +728,33 @@ const getAppsCloudflarePages = async ({ return apps; } +/** + * Return list of projects for Windmill integration + * @param {Object} obj + * @param {String} obj.accessToken - access token for Windmill API + * @returns {Object[]} apps - names of Windmill workspaces + * @returns {String} apps.name - name of Windmill workspace + */ +const getAppsWindmill = async ({ accessToken }: { accessToken: string }) => { + const { data } = await standardRequest.get( + `${INTEGRATION_WINDMILL_API_URL}/workspaces/list`, + { + headers: { + Authorization: `Bearer ${accessToken}`, + "Accept-Encoding": "application/json", + }, + } + ); + + const apps = data.map((a: any) => { + return { + name: a.name, + appId: a.id, + }; + }); + + return apps; +}; + + export { getApps };