Functions built on Firebase can also use Express.js routers to handle GET / POST / PUT / DELETE, etc., which are fully supported by Google and are the recommended way to implement these types of functions.
Further documentation can be found here:
https://firebase.google.com/docs/functions/http-events
Here is a working example built on Node.js
const functions = require('firebase-functions'); const express = require('express'); const cors = require('cors'); const app = express(); // Automatically allow cross-origin requests app.use(cors({ origin: true })); app.get('/hello', (req, res) => { res.end("Hello world from Firebase!"); }); // Expose Express API as a single Cloud Function: exports.widgets = functions.https.onRequest(app);
Then run firebase deploy, and this should compile your code and create a new widgets function. Note. You can rename widgets to any place. Ultimately, it will generate a URL to call the function.
source share