@serverless/aws-api-gateway
Advanced tools
Comparing version 1.2.0 to 2.0.0
{ | ||
"name": "@serverless/aws-api-gateway", | ||
"version": "1.2.0", | ||
"version": "2.0.0", | ||
"main": "./serverless.js", | ||
@@ -16,3 +16,4 @@ "publishConfig": { | ||
"@serverless/core": "^1.0.0", | ||
"aws-sdk": "^2.0.0" | ||
"aws-sdk": "^2.0.0", | ||
"p-retry": "^4.1.0" | ||
}, | ||
@@ -19,0 +20,0 @@ "devDependencies": { |
@@ -17,3 +17,4 @@ const AWS = require('aws-sdk') | ||
removeResources, | ||
removeOutdatedEndpoints | ||
removeOutdatedEndpoints, | ||
retry | ||
} = require('./utils') | ||
@@ -111,3 +112,3 @@ | ||
await createDeployment({ apig, apiId, stage }) | ||
await retry(() => createDeployment({ apig, apiId, stage })) | ||
@@ -114,0 +115,0 @@ config.url = `https://${apiId}.execute-api.${region}.amazonaws.com/${stage}` |
22
utils.js
@@ -0,3 +1,18 @@ | ||
const pRetry = require('p-retry') | ||
const { utils } = require('@serverless/core') | ||
const retry = (fn, opts = {}) => { | ||
return pRetry(fn, { | ||
retries: 5, | ||
minTimeout: 1000, | ||
factor: 2, | ||
onFailedAttempt: (error) => { | ||
if (error.code !== 'TooManyRequestsException') { | ||
throw error | ||
} | ||
}, | ||
...opts | ||
}) | ||
} | ||
const apiExists = async ({ apig, apiId }) => { | ||
@@ -52,3 +67,3 @@ try { | ||
const endpointExists = async ({ apig, apiId, endpoint }) => { | ||
const resourceId = await getPathId({ apig, apiId, endpoint }) | ||
const resourceId = await retry(() => getPathId({ apig, apiId, endpoint })) | ||
@@ -66,3 +81,3 @@ if (!resourceId) { | ||
try { | ||
await apig.getMethod(params).promise() | ||
await retry(() => apig.getMethod(params).promise()) | ||
return true | ||
@@ -550,3 +565,4 @@ } catch (e) { | ||
removeApi, | ||
removeOutdatedEndpoints | ||
removeOutdatedEndpoints, | ||
retry | ||
} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
41074
678
3
+ Addedp-retry@^4.1.0
+ Added@types/retry@0.12.0(transitive)
+ Addedp-retry@4.6.2(transitive)
+ Addedretry@0.13.1(transitive)