Skip to content

Commit f098420

Browse files
committed
feat: add api handler for workflows
1 parent c11e723 commit f098420

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

src/api-client.ts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { getConfig } from './utils.js'
22
import { got } from 'got'
3-
import { APIHealthResponse, APIProjectDetails, APIGithubOrgDetails, APIChecklistItem, APICheckItem } from './types.js'
3+
import { APIHealthResponse, APIProjectDetails, APIGithubOrgDetails, APIChecklistItem, APICheckItem, APIWorkflowItem } from './types.js'
44

55
export const apiClient = () => {
66
const config = getConfig()
@@ -70,3 +70,12 @@ export const getAllChecks = async (): Promise<APICheckItem[]> => {
7070
}
7171
return response.body as APICheckItem[]
7272
}
73+
74+
export const getAllWorkflows = async (): Promise<APIWorkflowItem[]> => {
75+
const client = apiClient()
76+
const response = await client.get('workflow', { responseType: 'json' })
77+
if (response.statusCode !== 200) {
78+
throw new Error(`Failed to get the data from the API: ${response.statusCode} ${response.body}`)
79+
}
80+
return response.body as APIWorkflowItem[]
81+
}

0 commit comments

Comments
 (0)