简体   繁体   中英

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 ?

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.

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) => {
  //
});

Use this firebase deploy --only functions:functionName

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM