-
Notifications
You must be signed in to change notification settings - Fork 5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add a new endpoint GET /benefits/<identity id>
to the user benefits API
#2606
base: main
Are you sure you want to change the base?
Conversation
We'll be adding a new path shortly and I think it makes sense to keep this lambda separate as the auth is different.
We'll have a single index and zip file for this handler and the new one.
I'd like to use a wildcard in the path here. According to https://aws.amazon.com/blogs/aws/api-gateway-update-new-features-simplify-api-development/ it should be possible.
3e4bd57
to
73c5301
Compare
GuApiGatewayWithLambdaByPath
GET /benefits/<identity id>
to the user benefits API
@@ -27,34 +27,20 @@ jest.mock('@modules/product-benefits/userBenefits', () => ({ | |||
getUserBenefits: () => ['adFree'], | |||
})); | |||
|
|||
describe('handler', () => { | |||
it('returns a 404 for an unrecognized path or HTTP method', async () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This diff is a bit messy but basically all that's happened here is the removal of the old 404 test, this now happens upstream and not in the lambda.
|
||
const userBenefitsResponse = await getUserBenefitsResponse( | ||
stage, | ||
new ProductCatalogHelper(await productCatalog.get()), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe create a Lazy<ProductCatalogHelper>
at the top level rather than a productCatalog and then creating a new helper every time?
}; | ||
} | ||
}; | ||
export { benefitsMeHandler } from './benefitsMe'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do we need this file now?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This acts as the single entry point for esbuild
which gives access to both handlers (but means we can still keep the handlers in separate files).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good 👍
What does this change?
Add a new endpoint
/benefits/<identity id>
which is auth'd using anx-api-key
header (enforced in API Gateway). Because the auth is performed differently, at the API Gateway, I've migrated to using theGuApiGatewayWithLambdaByPath
with a lambda per endpoint.This will be called from support-frontend to prevent a user who already has a the
adFree
benefit from purchasing Guardian Ad-Lite.Note: in the first implementation the endpoint does not know anything about internal users
How to test
I've deployed to CODE and tested.
Note: this requires a dangerous deploy in Riff Raff because the old lambda is deleted.
How can we measure success?
Have we considered potential risks?
Images
Accessibility