mirror of
https://github.com/awatertrevi/infisical.git
synced 2026-09-22 13:39:35 +00:00
Merge pull request #1569 from Infisical/render-integration
Add pagination to getAppsRender
This commit is contained in:
@@ -260,20 +260,44 @@ const getAppsGithub = async ({ accessToken }: { accessToken: string }) => {
|
|||||||
* Return list of services for Render integration
|
* Return list of services for Render integration
|
||||||
*/
|
*/
|
||||||
const getAppsRender = async ({ accessToken }: { accessToken: string }) => {
|
const getAppsRender = async ({ accessToken }: { accessToken: string }) => {
|
||||||
const res = (
|
const apps: Array<{ name: string; appId: string }> = [];
|
||||||
await request.get<{ service: { name: string; id: string } }[]>(`${IntegrationUrls.RENDER_API_URL}/v1/services`, {
|
let hasMorePages = true;
|
||||||
headers: {
|
const perPage = 100;
|
||||||
Authorization: `Bearer ${accessToken}`,
|
let cursor;
|
||||||
Accept: "application/json",
|
|
||||||
"Accept-Encoding": "application/json"
|
|
||||||
}
|
|
||||||
})
|
|
||||||
).data;
|
|
||||||
|
|
||||||
const apps = res.map((a) => ({
|
interface RenderService {
|
||||||
name: a.service.name,
|
cursor: string;
|
||||||
appId: a.service.id
|
service: { name: string; id: string };
|
||||||
}));
|
}
|
||||||
|
|
||||||
|
while (hasMorePages) {
|
||||||
|
const res: RenderService[] = (
|
||||||
|
await request.get<RenderService[]>(`${IntegrationUrls.RENDER_API_URL}/v1/services`, {
|
||||||
|
params: new URLSearchParams({
|
||||||
|
...(cursor ? { cursor: String(cursor) } : {}),
|
||||||
|
limit: String(perPage)
|
||||||
|
}),
|
||||||
|
headers: {
|
||||||
|
Authorization: `Bearer ${accessToken}`,
|
||||||
|
Accept: "application/json",
|
||||||
|
"Accept-Encoding": "application/json"
|
||||||
|
}
|
||||||
|
})
|
||||||
|
).data;
|
||||||
|
|
||||||
|
res.forEach((a) => {
|
||||||
|
apps.push({
|
||||||
|
name: a.service.name,
|
||||||
|
appId: a.service.id
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
if (res.length < perPage) {
|
||||||
|
hasMorePages = false;
|
||||||
|
} else {
|
||||||
|
cursor = res[res.length - 1].cursor;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return apps;
|
return apps;
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user