Created
September 13, 2020 20:21
-
-
Save NickFoden/19a270d679fbf9fcf9def7c91c180fb9 to your computer and use it in GitHub Desktop.
Firebase Functions
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const functions = require("firebase-functions"); | |
const express = require("express"); | |
const admin = require("firebase-admin") | |
admin.initializeApp(functions.config().firebase) | |
// once you have the admin initialized then can access other parts of project | |
// say the real time database | |
const realTimeDB = admin.database(); | |
const userRef = realTimeDB.ref("users").child("user_uid_or_such_here"); | |
const app = express(); | |
app.get("/", (req, res) => { | |
res.status(200).send({ data: "wordly hellos" }); | |
}); | |
exports.app = functions.https.onRequest(app); | |
// Chron jobs | |
//https://firebase.google.com/docs/functions/schedule-functions | |
// example at 12:01 am every first of the month NYC time | |
exports.chooseWhateverNameYouWant = functions.pubsub | |
.schedule("01 0 1 * *") | |
.timeZone("America/New_York") | |
.onRun((context) => { | |
// do the stuff | |
}) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment