UNPKG

1.72 kBMarkdownView Raw
1# Firebase SDK for Cloud Functions
2
3The `firebase-functions` package provides an SDK for defining Cloud Functions for Firebase.
4
5Cloud 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
9Learn 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
11Here 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
18If 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
26const functions = require("firebase-functions");
27const notifyUsers = require("./notify-users");
28
29exports.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
37To contribute a change, [check out the contributing guide](.github/CONTRIBUTING.md).
38
39## License
40
41© Google, 2017. Licensed under [The MIT License](LICENSE).