You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feat: add a Firebase Functions step by step guide (fastify#5318)
* feat: add a Firebase Functions step by step guide
This PR adds a new section to the Serverless Guide on the website that explains how to use Fastify as the wrapper around Firebase's own onRequest HTTP handler
Signed-off-by: Liran Tal <[email protected]>
* Update docs/Guides/Serverless.md
Co-authored-by: James Sumners <[email protected]>
Signed-off-by: Liran Tal <[email protected]>
* Update docs/Guides/Serverless.md
Co-authored-by: James Sumners <[email protected]>
Signed-off-by: Liran Tal <[email protected]>
* Update docs/Guides/Serverless.md
Co-authored-by: James Sumners <[email protected]>
Signed-off-by: Liran Tal <[email protected]>
* Update docs/Guides/Serverless.md
Co-authored-by: James Sumners <[email protected]>
Signed-off-by: Liran Tal <[email protected]>
---------
Signed-off-by: Liran Tal <[email protected]>
Co-authored-by: James Sumners <[email protected]>
Final step is to export the Fastify app instance to Firebase's own
332
+
`onRequest()` function so it can pass the request and reply objects to it:
333
+
334
+
```js
335
+
exports.app=onRequest(fastifyApp)
336
+
```
337
+
338
+
### Local test
339
+
340
+
Install the Firebase tools functions so you can use the CLI:
341
+
342
+
```bash
343
+
npm i -g firebase-tools
344
+
```
345
+
346
+
Then you can run your function locally with:
347
+
348
+
```bash
349
+
firebase emulators:start --only functions
350
+
```
351
+
352
+
### Deploy
353
+
354
+
Deploy your Firebase Functions with:
355
+
356
+
```bash
357
+
firebase deploy --only functions
358
+
```
359
+
360
+
#### Read logs
361
+
362
+
Use the Firebase tools CLI:
363
+
364
+
```bash
365
+
firebase functions:log
366
+
```
367
+
368
+
### References
369
+
- [Fastify on Firebase Functions](https://github.com/lirantal/lemon-squeezy-firebase-webhook-fastify/blob/main/package.json)
370
+
- [An article about HTTP webhooks on Firebase Functions and Fastify: A Practical Case Study with Lemon Squeezy](https://lirantal.com/blog/http-webhooks-firebase-functions-fastify-practical-case-study-lemon-squeezy)
371
+
372
+
263
373
## Google Cloud Run
264
374
265
375
Unlike AWS Lambda or Google Cloud Functions, Google Cloud Run is a serverless
0 commit comments