Skip to content
This repository has been archived by the owner on Nov 4, 2023. It is now read-only.

Commit

Permalink
Merge pull request #2 from jeromemacias/fastify_29
Browse files Browse the repository at this point in the history
Fix Fastify < 2.10.0 compatibility
  • Loading branch information
jeromemacias authored Dec 6, 2020
2 parents fe46807 + 6186100 commit 297f57e
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
7 changes: 7 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,13 @@ node_js:
- "lts/*"
- "node"

env:
- FASTIFY_VERSION=^2.0.0
- FASTIFY_VERSION=2.9.0

before_script:
- npm i --no-save fastify@$FASTIFY_VERSION

script:
- npm run lint-ci
- npm run test-ci
Expand Down
6 changes: 4 additions & 2 deletions plugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,11 +77,13 @@ function plugin (fastify, options, next) {
return done()
}

if (reply.statusCode === 429) {
const statusCode = reply.statusCode || reply.res.statusCode

if (statusCode === 429) {
segment.addThrottleFlag()
}

const cause = AWSXRay.utils.getCauseTypeFromHttpStatus(reply.statusCode)
const cause = AWSXRay.utils.getCauseTypeFromHttpStatus(statusCode)
if (cause) {
segment[cause] = true
}
Expand Down

0 comments on commit 297f57e

Please sign in to comment.