'firebase how to deploy only specific function of express() app

I use an Express app on cloud functions deployed with the Firebase CLI. What is the way to deploy only one specific function?

const app = express();

app.post('/sample-1', (req, res) => {
  //
});

app.post('/sample-2', (req, res) => {
  //
});

when I try:

firebase deploy --only functions:app

it deploys all app functions (sample-1, sample-2 ... )

Is there a way to deploy only a specific Eexpress app function like sample-1 ?



Solution 1:[1]

No, there is not. The entire express app will be updated every time. In the end, it is really just one function that has internal routing for each path.

Solution 2:[2]

You cannot deploy only sample-1 or sample-2 because both are in app, although you make make another instance of express() -> const appv2 = express(); or something like that to export it in the end but you have to measure you benefit of all that.

const app = express();
const appV2 = express();

app.post('/sample-1', (req, res) => {
  //
});

appV2.post('/sample-2', (req, res) => {
  //
});

Solution 3:[3]

Use this firebase deploy --only functions:functionName

You can select multiple like firebase deploy --only functions:function1, functions:func2

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Doug Stevenson
Solution 2 Zarko Boyadzhiev
Solution 3 Simeon