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
grouped all websockets-related properties under provider.websocket na… #10963
base: main
Are you sure you want to change the base?
Changes from 2 commits
e784f04
7578f22
1dd2ec3
9183f30
6f85676
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -207,6 +207,9 @@ module.exports = { | |
|
||
// Websockets API | ||
getWebsocketsApiName() { | ||
if (_.get(this.provider.serverless.service.provider.websockets)) { | ||
return `${this.provider.serverless.service.provider.websockets.apiName}`; | ||
} | ||
if ( | ||
this.provider.serverless.service.provider.websocketsApiName && | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We should still support the old syntax as well, but first check for the new one There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is the only one I can't get to pass the tests. I used the code below. Any suggestions that might point me in the right direction? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This should also follow a similar approach with using Small request - when pasting the code samples, please format them all with code blocks as it's hard to read unformatted code. Thanks in advance 🙇 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. All the test are passing now. Should I just push my changes to the branch or push and create a new pull request? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The tests might be passing, but just glancing over the code I see that a lot of stuff listed in the issue is not addressed, I'm also pretty sure it's going to break in a few scenarios. Are you sure the PR in current form is ready for a deeper review? I can also review it in the current state and provide feedback - please let me know 🙌 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I appreciate your feedback. This is a learning process for me and I have identified several things I could have done better process wise and learned about lodash in the process. I'd like to address all the requirements for this issue. I see that I missed the deprecation.md. I assume that serverless._logDeprecation is a terminal command. I'll let you know when i resolve this and the other issues you mentioned. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hello @BillConley01 - no worries, this issue is actually a bit more complex that it might've seem at first - I'll try to provide more details to help you understand the scope better. For the potential breaking scenario, let's consider this check
In the check above, we're checking if the Another example we can find here:
This is a part of the code that resolves the description. In the ternary here, we are checking if Hope that helps a bit - if something is not clear, sorry about that and please let me know, I'll try to explain it a bit better 🙇 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks for the explanation and I apologize for the delay. A family member passed away last week. I addressed the issues mentioned and updated the readme files. The only thing I am unsure of is where/how to add the deprecation code? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hey @BillConley01 - no worries about the delay and really sorry about your loss. As for the deprecation code, you can see how that can be implemented e.g. in this PR - #8277 If you have any additional questions, feel free to reach out 💯 |
||
typeof this.provider.serverless.service.provider.websocketsApiName === 'string' | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,18 +13,24 @@ module.exports = { | |
|
||
this.websocketsApiLogicalId = this.provider.naming.getWebsocketsApiLogicalId(); | ||
|
||
const RouteSelectionExpression = | ||
this.serverless.service.provider.websocketsApiRouteSelectionExpression || | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We should still support the old syntax, but checking the new one first when resolving the property There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I keep getting more test failures. I think I am in above my head on this? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What is currently causing you troubles? From what I see in the errors - it's failing because it tries to access There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. would something like this resolve const RouteSelectionExpression? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think the best way would be to use |
||
'$request.body.action'; | ||
const RouteSelectionExpression = _.get( | ||
this.provider, | ||
'serverless.service.provider.websockets.routeSelectionExpression' | ||
) | ||
? this.serverless.service.provider.websockets.routeSelectionExpression || | ||
'$request.body.action' | ||
: this.serverless.service.provider.websocketsRouteSelectionExpression || | ||
'$request.body.action'; | ||
|
||
_.merge(this.serverless.service.provider.compiledCloudFormationTemplate.Resources, { | ||
[this.websocketsApiLogicalId]: { | ||
Type: 'AWS::ApiGatewayV2::Api', | ||
Properties: { | ||
Name: this.provider.naming.getWebsocketsApiName(), | ||
RouteSelectionExpression, | ||
Description: | ||
this.serverless.service.provider.websocketsDescription || 'Serverless Websockets', | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We should still support the old syntax, but checking the new one first when resolving the property |
||
Description: this.serverless.service.provider.websockets | ||
? this.serverless.service.provider.websockets.description | ||
: this.serverless.service.provider.websocketsDescription || 'Serverless Websockets', | ||
ProtocolType: 'WEBSOCKET', | ||
}, | ||
}, | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -30,8 +30,9 @@ module.exports = { | |
ApiId: this.provider.getApiGatewayWebsocketApiId(), | ||
// DeploymentId is generated at deployment.js file | ||
StageName: this.provider.getStage(), | ||
Description: | ||
this.serverless.service.provider.websocketsDescription || 'Serverless Websockets', | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We should still support the old syntax, but checking the new one first when resolving the property There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ok, I will add the old back to those four areas. Thanks. |
||
Description: this.serverless.service.provider.websockets | ||
? this.serverless.service.provider.websockets.description | ||
: this.serverless.service.provider.websocketsDescription || 'Serverless Websockets', | ||
}, | ||
}; | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1198,6 +1198,15 @@ class AwsProvider { | |
websocketsApiName: { type: 'string' }, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We should still support the old properties - removing them is a breaking change and we want to avoid that until releasing new major in the future - hence the need for deprecation first |
||
websocketsApiRouteSelectionExpression: { type: 'string' }, | ||
websocketsDescription: { type: 'string' }, | ||
websockets: { | ||
type: 'object', | ||
properties: { | ||
apiName: { type: 'string' }, | ||
apiRouteSelectionExpression: { type: 'string' }, | ||
description: { type: 'string' }, | ||
}, | ||
additionalProperties: false, | ||
}, | ||
}, | ||
}, | ||
function: { | ||
|
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.
Could you move
websockets
belowapiGateway
? (I thinkapiGateway
is used by more people, we should make it a bit more visible)Also there's the
websocketApiId
property that isn't moved towebsockets
, is that intentional?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.
Matthieu, I will move Websockets after APIGateway. I didn't group websocketApiID with Websockets because it was already a property of APIGateway?