-
Notifications
You must be signed in to change notification settings - Fork 2.6k
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: add @remix-run/google-cloud-functions
package
#3397
Conversation
firebase-admin is a peer dependency of firebase-functions
Hi @penx, Welcome, and thank you for contributing to Remix! Before we consider your pull request, we ask that you sign our Contributor License Agreement (CLA). We require this only once. You may review the CLA and sign it by adding your name to contributors.yml. Once the CLA is signed, the If you have already signed the CLA and received this response in error, or if you have any questions, please contact us at [email protected]. Thanks! - The Remix team |
Thank you for signing the Contributor License Agreement. Let's get this merged! 🥳 |
@@ -82,7 +83,7 @@ | |||
"eslint-plugin-markdown": "^2.2.1", | |||
"eslint-plugin-prefer-let": "^3.0.1", | |||
"express": "^4.17.1", | |||
"jest": "^27.5.1", | |||
"jest": "^28.1.0", |
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 is required in order to
import { getTestServer } from "@google-cloud/functions-framework/testing";
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 elaborate why this is necessary?
I don't see any indication in @google-cloud/functions-framework
why jest@^28.0.0
is necessary.
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.
import { getTestServer } from "@google-cloud/functions-framework/testing";
This import makes use of package exports:
Full support for this was added in Jest 28.
In Jest 27, server-test.ts will fail saying it cannot find @google-cloud/functions-framework/testing
.
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.
Sure, I'll open up a PR for the Jest upgrade shortly, which will need to be merged before this one. I can remove the commits from this branch too.
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.
Let's do this in a separate PR instead, so we keep this PR focussed.
I think the Jest 28 change is also causing some tests to fail, so we could solve them in isolation in the new PR.
@remix-run/google-cloud-functions
package
@MichaelDeBoey sure, I was working on this independently and was going to name it It appears #2266 has the same purpose but with a slightly different approach. I would suggest using my approach here for various reasons: ImplementationrawBody#2266 has the following code which I think is the main difference: /**
* Google Cloud Functions includes middleware that processes incoming requests based on their headers and sets the request body to
* a javascript object. But Remix doesn't like that, remix has its own request processing logic, so we have to turn the body back into
* something that Remix is expecting. In this case a Buffer with URLSearchParams encoded data works.
*
* @param req the request passed in from the Google Cloud Function
*/
function createRemixBody(req: GcfRequest) {
let s = new Readable()
s.push((new URLSearchParams(req.body).toString()).toString());
s.push(null);
return s;
} We don't need to create a new buffer on each request as Here's the equivalent code in my version: if (req.method !== "GET" && req.method !== "HEAD") {
init.body = req.rawBody;
} This comes from @ryanflorence 's recommendation on Discord and gist Types
Testing
Naming
|
@penx I suggest you to join forces with @eastlondoner on #2266, since he started first on this idea. This way we can focus on keeping all related discussions on the same PR. |
I've left feedback on #2266 and opened eastlondoner#1 with the unit tests |
Required adapter in order to provide example of deploying to Firebase functions
Closes: #125
Closes: #211
Testing Strategy: