mirror of
https://github.com/awatertrevi/infisical.git
synced 2026-10-07 23:27:35 +00:00
Paginate Netlify sites
This commit is contained in:
@@ -41,7 +41,7 @@ export const getMe = async (req: Request, res: Response) => {
|
|||||||
try {
|
try {
|
||||||
user = await User
|
user = await User
|
||||||
.findById(req.user._id)
|
.findById(req.user._id)
|
||||||
.select('+publicKey +encryptedPrivateKey +iv +tag');
|
.select('+salt +publicKey +encryptedPrivateKey +iv +tag +encryptionVersion +protectedKey +protectedKeyIV +protectedKeyTag');
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
Sentry.setUser({ email: req.user.email });
|
Sentry.setUser({ email: req.user.email });
|
||||||
Sentry.captureException(err);
|
Sentry.captureException(err);
|
||||||
|
|||||||
@@ -197,21 +197,40 @@ const getAppsVercel = async ({
|
|||||||
* @returns {String} apps.name - name of Netlify site
|
* @returns {String} apps.name - name of Netlify site
|
||||||
*/
|
*/
|
||||||
const getAppsNetlify = async ({ accessToken }: { accessToken: string }) => {
|
const getAppsNetlify = async ({ accessToken }: { accessToken: string }) => {
|
||||||
let apps;
|
const apps: any = [];
|
||||||
try {
|
try {
|
||||||
const res = (
|
let page = 1;
|
||||||
await request.get(`${INTEGRATION_NETLIFY_API_URL}/api/v1/sites`, {
|
const perPage = 10;
|
||||||
|
let hasMorePages = true;
|
||||||
|
|
||||||
|
// paginate through all sites
|
||||||
|
while (hasMorePages) {
|
||||||
|
const params = new URLSearchParams({
|
||||||
|
page: String(page),
|
||||||
|
per_page: String(perPage)
|
||||||
|
});
|
||||||
|
|
||||||
|
const { data } = await request.get(`${INTEGRATION_NETLIFY_API_URL}/api/v1/sites`, {
|
||||||
|
params,
|
||||||
headers: {
|
headers: {
|
||||||
Authorization: `Bearer ${accessToken}`,
|
Authorization: `Bearer ${accessToken}`,
|
||||||
'Accept-Encoding': 'application/json'
|
'Accept-Encoding': 'application/json'
|
||||||
}
|
}
|
||||||
})
|
});
|
||||||
).data;
|
|
||||||
|
data.map((a: any) => {
|
||||||
|
apps.push({
|
||||||
|
name: a.name,
|
||||||
|
appId: a.site_id
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
if (data.length < perPage) {
|
||||||
|
hasMorePages = false;
|
||||||
|
}
|
||||||
|
|
||||||
apps = res.map((a: any) => ({
|
page++;
|
||||||
name: a.name,
|
}
|
||||||
appId: a.site_id,
|
|
||||||
}));
|
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
Sentry.setUser(null);
|
Sentry.setUser(null);
|
||||||
Sentry.captureException(err);
|
Sentry.captureException(err);
|
||||||
|
|||||||
@@ -75,7 +75,6 @@ let privateKey;
|
|||||||
throw new Error('Insufficient details to decrypt private key');
|
throw new Error('Insufficient details to decrypt private key');
|
||||||
}
|
}
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.error(err);
|
|
||||||
throw new Error('Failed to decrypt private key');
|
throw new Error('Failed to decrypt private key');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user