-
Notifications
You must be signed in to change notification settings - Fork 18
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
feat: handle number and object responses correctly in functions #440
Conversation
✅ Deploy Preview for netlify-plugin-gatsby-demo ready!
To edit notification comments on pull requests, go to your Netlify site settings. |
c7ce05c
to
43e869a
Compare
package.json
Outdated
@@ -38,7 +38,7 @@ | |||
}, | |||
"devDependencies": { | |||
"@netlify/build": "^27.4.0", | |||
"@netlify/eslint-config-node": "6.0.0", | |||
"@netlify/eslint-config-node": "5.1.8", |
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.
downgraded to avoid lint errors with module resolution after syncing package.json and package-lock.json
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.
Odd that this is happening 🤔 Is it the rules within this project that are causing these issues?
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.
Are the errors related to the files you've changed, or elsewhere? If they're not related to your changes then it seems like this shouldbe a different PR: i.e. you do a separate PR to update the package-lock and if that breaks the linting, make the linting changes in there rather than in this unrelated PR
plugin/package.json
Outdated
@@ -71,7 +72,7 @@ | |||
"npm-run-all": "^4.1.5", | |||
"rimraf": "^3.0.2", | |||
"tmp-promise": "^3.0.3", | |||
"typescript": "^4.5.2" | |||
"typescript": "4.6.4" |
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.
upgraded to avoid ts.resolveTypeReferenceDirective
error after syncing package.json and package-lock.json
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.
[dust] Should this be the following instead?
"typescript": "4.6.4" | |
"typescript": "^4.6.4" |
Or do we want to start pinning to specific versions to prevent issues going forward during package upgrades?
@@ -133,7 +134,7 @@ export const createResponseObject = ({ onResEnd }) => { | |||
response.statusCode = statusCode | |||
}, | |||
}) | |||
res.headers = { 'content-type': 'text/plain; charset=utf-8' } | |||
res.headers = { 'content-type': 'text/html; charset=utf-8' } |
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.
default content type changed to html to match gatsby serve
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.
LGTM 🚀
package.json
Outdated
@@ -38,7 +38,7 @@ | |||
}, | |||
"devDependencies": { | |||
"@netlify/build": "^27.4.0", | |||
"@netlify/eslint-config-node": "6.0.0", | |||
"@netlify/eslint-config-node": "5.1.8", |
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.
Odd that this is happening 🤔 Is it the rules within this project that are causing these issues?
plugin/package.json
Outdated
@@ -71,7 +72,7 @@ | |||
"npm-run-all": "^4.1.5", | |||
"rimraf": "^3.0.2", | |||
"tmp-promise": "^3.0.3", | |||
"typescript": "^4.5.2" | |||
"typescript": "4.6.4" |
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.
[dust] Should this be the following instead?
"typescript": "4.6.4" | |
"typescript": "^4.6.4" |
Or do we want to start pinning to specific versions to prevent issues going forward during package upgrades?
954aa7d
to
2e35993
Compare
2e35993
to
9ac9098
Compare
Summary
We currently handle Gatsby's function response helpers (basiclaly Express's
send
andjson
) by adding our own implementations to the mocked HTTP ServerResponse object that is sent back from the function lambda.However, our implementations don't handle some types in the same way as Express and this PR addresses that.
Specifically:
send
are now stringified unless they are Buffers (which are now served with the correct content type)send
are used as the status code and the relevant status message is sent as the bodyTest plan
Tests are in progress
Relevant links (GitHub issues, Notion docs, etc.) or a picture of cute animal