-
Notifications
You must be signed in to change notification settings - Fork 33
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: new rawBody type on SvelteKit req #123
Conversation
PR to fix that TODO here: sveltejs/kit#2248 I'm not sure why |
Right, so I am no expert of the Buffer/Uint8Array types, does |
It seems the only |
Yeah. It was to change it to something like
I'm not an expert on this either. All I could do is check the other adapters and Google search it
No. I'm relatively sure you can only set that on responses |
Great, thanks for the feedback and information @benmccann much appreciated. |
Finally, the e2e test suite will:
The below log shows the [hosting] Rewriting /todos to http://localhost:5001/demo/us-central1/sveltekit for local Function sveltekit
i functions: Beginning execution of "us-central1-sveltekit"
> {"severity":"INFO","message":"Initialising SvelteKit SSR Handler"}
> {"severity":"INFO","message":"SvelteKit SSR Handler initialised!"}
> {"severity":"INFO","message":"Requested resource: /todos"}
⚠ External network resource requested!
- URL: "api.svelte.dev/todos/bb7e4cad-bbd0-4326-ab27-f2e11796f478"
- Be careful, this may be a production service.
0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0
100 2991 0 2991 0 0 4762 0 --:--:-- --:--:-- --:--:-- 4755
100 2991 0 2991 0 0 4762 0 --:--:-- --:--:-- --:--:-- 4755
====> Test POST to '/todos' API
i hosting: 127.0.0.1 - - [23/Aug/2021:12:07:28 +0000] "GET /todos HTTP/1.1" 200 - "-" "curl/7.68.0"
i functions: Finished "us-central1-sveltekit" in ~1s
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
[hosting] Rewriting /todos.json to http://localhost:5001/demo/us-central1/sveltekit for local Function sveltekit
i functions: Beginning execution of "us-central1-sveltekit"
> {"severity":"INFO","message":"Requested resource: /todos.json"}
⚠ External network resource requested!
- URL: "api.svelte.dev/todos/0a52e7d5-25d4-4b12-b307-38756d00bbcb"
- Be careful, this may be a production service.
0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0
i hosting: 127.0.0.1 - - [23/Aug/2021:12:07:29 +0000] "POST /todos.json HTTP/1.1" 201 - "http://localhost:8685/todos" "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:91.0) Gecko/20100101 Firefox/91.0"
i functions: Finished "us-central1-sveltekit" in ~1s
100 277 0 100 100 177 398 705 --:--:-- --:--:-- --:--:-- 1103
{"uid":"f21fb8bfa277444190d6636331cd178c2929","created_at":1629720449095,"text":"asdf","done":false} 🎉 If my new |
Summary
Update to the latest SvelteKit request type.
Labelled as
feat
as this is breaking.Fixes: #122
Details
The new type is
Uint8Array
, which we already get as a Buffer type (Node.js class which extends Uint8Array) from theimport('firebase-functions').https.Request
type, so this simplifies things a bit.The assignment of
headers
is currently a type error:but looking at theHeaders
type in SvelteKit is seems this may not be an issue in futureIt was an issue and worked around. deprecated code snippet here
so I think it is okay to leave the
IncomingHttpHeaders
type for now as it hasn't been causing issues for people so far.Thoughts @benmccann?
Tasks
string[]
from headerstoSvelteKit*
functions. Use requests generated from SvelteKit todos template?toSvelteKitRequest
with GETtoSvelteKitRequest
with POSTfirebase-functions.https.request
type is wrong asrawBody
is optional as shown in upstream Node.js Functions Framework https://github.com/GoogleCloudPlatform/functions-framework-nodejs/blob/e76b9f6c49bcf8c12d8206212cae84cfb931a077/src/invoker.ts#L44 - fix: rawBody is optional type in funcs framework firebase/firebase-functions#959