Skip to content

Commit

Permalink
Fix unintended limitation with fetching APIs
Browse files Browse the repository at this point in the history
  • Loading branch information
amazon-meaisiah committed May 15, 2020
1 parent 4e4f4d5 commit 35c5058
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion lambdas/backend/routes/admin/catalog/visibility.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,26 @@ const util = require('../../../util')

const inspect = o => JSON.stringify(o, null, 2)

// Let's try to minimize how many calls we make here.
const MAX_REST_API_LIMIT = 500

exports.get = async (req, res) => {
console.log(`GET /admin/catalog/visibility for Cognito ID: ${util.getCognitoIdentityId(req)}`)
try {
const visibility = { apiGateway: [] }
const catalogObject = await util.catalog()
const apis = (await util.apigateway.getRestApis().promise()).items
let restApiResult = await util.apigateway.getRestApis({
limit: MAX_REST_API_LIMIT
}).promise()
const apis = restApiResult.items

while (restApiResult.position != null) {
restApiResult = await util.apigateway.getRestApis({
limit: MAX_REST_API_LIMIT,
position: restApiResult.position
}).promise()
for (const api of restApiResult.apis) apis.push(api)
}

console.log(`apis: ${inspect(apis)}`)

Expand Down

0 comments on commit 35c5058

Please sign in to comment.