-
Notifications
You must be signed in to change notification settings - Fork 64
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
Moving local serverless server into separate package #404
Moving local serverless server into separate package #404
Conversation
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.
Took a quick pass (not super deep).
@@ -0,0 +1,71 @@ | |||
# @hubspot/local-serverless-server |
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.
I think we should come up with another name for the package. My suggestion would be something that doesn't have local
in the name because I think it could be used for things like testing a serverless function in a CI situation and for it to forgo the pun. Perhaps we could use something along the lines of serverless-function-runner
or serverless-runner
. I think the model of this being about execution not a server is best. Could even use execute
or executor
. Naming is hard…
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.
I just wanted the name to focus on the fact that we need to run a server to test serverLESS functions 😂
There is an express
server that allows the endpoints to be accessed locally
For more information on using these tools, see [Local Development Tooling: Getting Started](https://designers.hubspot.com/tutorials/getting-started-with-local-development) | ||
|
||
### Installation | ||
|
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.
I'd suggest some docs that state that this is intended for use with the CLI with a link to either the docs on developers.hubspot.com
or the NPM package.
HUBSPOT_CONTACT_VID // default: 123 | ||
HUBSPOT_CONTACT_IS_LOGGED_IN // default: false | ||
HUBSPOT_CONTACT_LIST_MEMBERSHIPS // default: [] | ||
``` |
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.
I think we should probably be using either .env
or a config file for this and be consider when these may be things that may make sense to live with the project in source control.
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.
Good point, I'll move this out.
"HUBSPOT_CONTACT_VID": 456, | ||
"HUBSPOT_CONTACT_IS_LOGGED_IN": true, | ||
"HUBSPOT_CONTACT_LIST_MEMBERSHIPS": ["some", "memberships"] | ||
} |
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.
Can you explain this a bit more? I thought we were faking the way this works when executing in the HubSpot serverless infra?
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.
The way production works is it grabs the cookie value for hubspotutk
which is not an actual contact id. It's some sort of hashed value that the BE understands and can convert into a contact. AFAIK there is not an API endpoint to get the contact data using this value, and I'm not sure we want there to be an endpoint for this.
So instead, in order to facilitate testing around the contact
prop that gets passed into the function, this allows for customization of the data that is passed in. By setting values for these environment variables, that mocked value will be passed into the function for testing.
Going to merge this back into the |
Description and Context
Moving the local serverless testing logic out of the cms-cli command file into a separate lerna package.
This is currently still WIP, I would love any feedback on how this is being executed. Specifically...
start
) make sense -- it takes anoptions
object shaped likeWho to Notify
@gcorne