|
1
|
/** |
|
2
|
* Import function triggers from their respective submodules: |
|
3
|
* |
|
4
|
* const {onCall} = require("firebase-functions/v2/https"); |
|
5
|
* const {onDocumentWritten} = require("firebase-functions/v2/firestore"); |
|
6
|
* |
|
7
|
* See a full list of supported triggers at https://firebase.google.com/docs/functions |
|
8
|
*/ |
|
9
|
|
|
10
|
const {setGlobalOptions} = require("firebase-functions"); |
|
11
|
const {onRequest} = require("firebase-functions/https"); |
|
12
|
const logger = require("firebase-functions/logger"); |
|
13
|
|
|
14
|
// For cost control, you can set the maximum number of containers that can be |
|
15
|
// running at the same time. This helps mitigate the impact of unexpected |
|
16
|
// traffic spikes by instead downgrading performance. This limit is a |
|
17
|
// per-function limit. You can override the limit for each function using the |
|
18
|
// `maxInstances` option in the function's options, e.g. |
|
19
|
// `onRequest({ maxInstances: 5 }, (req, res) => { ... })`. |
|
20
|
// NOTE: setGlobalOptions does not apply to functions using the v1 API. V1 |
|
21
|
// functions should each use functions.runWith({ maxInstances: 10 }) instead. |
|
22
|
// In the v1 API, each function can only serve one request per container, so |
|
23
|
// this will be the maximum concurrent request count. |
|
24
|
setGlobalOptions({ maxInstances: 10 }); |
|
25
|
|
|
26
|
// Create and deploy your first functions |
|
27
|
// https://firebase.google.com/docs/functions/get-started |
|
28
|
|
|
29
|
// exports.helloWorld = onRequest((request, response) => { |
|
30
|
// logger.info("Hello logs!", {structuredData: true}); |
|
31
|
// response.send("Hello from Firebase!"); |
|
32
|
// }); |