firebase / firebase-functions

Firebase SDK for Cloud Functions
https://firebase.google.com/docs/functions/
MIT License
1.03k stars 202 forks source link

Change default entrypoint of the firebase-functions package to v2 instead of v1 #1594

Closed taeold closed 2 months ago

taeold commented 3 months ago

On the same note of gcloud functions commands defaulting to 2nd Gen functions, Firebase Functions SDK will change default entrypoint of the SDK to point to the v2 namespace in the next major release.

Before:

const functions = require('firebase-functions');

// This is a v1 callable function
exports.v1 = functions.https.onCall((data, context) => {
  // ...
});

After:

const functions = require('firebase-functions');

// This is a v2 callable function
exports.v2 = functions.https.onCall((req) => {
  // ...
});

// Preferred style 
const { onCall } = require('firebase-functions/https');

// This is a v2 callable function
exports.v2 = onCall((req) => {
  // ...
});