UNPKG

1.76 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 { onValueCreated } = require("firebase-functions/database");
27const logger = require("firebase-functions/logger");
28const notifyUsers = require("./notify-users");
29
30exports.newPost = onValueCreated({ ref: "/posts/{postId}" }, (event) => {
31 logger.info("Received new post with ID:", event.params.postId);
32 return notifyUsers(event.data.val());
33});
34```
35
36## Contributing
37
38To contribute a change, [check out the contributing guide](.github/CONTRIBUTING.md).
39
40## License
41
42© Google, 2017. Licensed under [The MIT License](LICENSE).