1 | # Firebase SDK for Cloud Functions
|
2 |
|
3 | The `firebase-functions` package provides an SDK for defining Cloud Functions for Firebase.
|
4 |
|
5 | Cloud Functions is a hosted, private, and scalable Node.js environment where you can run JavaScript code. The Firebase SDK for Cloud Functions integrates the Firebase platform by letting you write code that responds to events and invokes functionality exposed by other Firebase features.
|
6 |
|
7 | ## Learn more
|
8 |
|
9 | Learn more about the Firebase SDK for Cloud Functions in the [Firebase documentation](https://firebase.google.com/docs/functions/) or [check out our samples](https://github.com/firebase/functions-samples).
|
10 |
|
11 | Here are some resources to get help:
|
12 |
|
13 | - Start with the quickstart: https://firebase.google.com/docs/functions/write-firebase-functions
|
14 | - Go through the guide: https://firebase.google.com/docs/functions/
|
15 | - Read the full API reference: https://firebase.google.com/docs/reference/functions/
|
16 | - Browse some examples: https://github.com/firebase/functions-samples
|
17 |
|
18 | If the official documentation doesn't help, try asking through our official support channels: https://firebase.google.com/support/
|
19 |
|
20 | _Please avoid double posting across multiple channels!_
|
21 |
|
22 | ## Usage
|
23 |
|
24 | ```js
|
25 | // functions/index.js
|
26 | const functions = require("firebase-functions");
|
27 | const notifyUsers = require("./notify-users");
|
28 |
|
29 | exports.newPost = functions.database.ref("/posts/{postId}").onCreate((snapshot, context) => {
|
30 | functions.logger.info("Received new post with ID:", context.params.postId);
|
31 | return notifyUsers(snapshot.val());
|
32 | });
|
33 | ```
|
34 |
|
35 | ## Contributing
|
36 |
|
37 | To contribute a change, [check out the contributing guide](.github/CONTRIBUTING.md).
|
38 |
|
39 | ## License
|
40 |
|
41 | © Google, 2017. Licensed under [The MIT License](LICENSE).
|