Last active
January 19, 2019 14:15
-
-
Save jperasmus/d248707cc4a4abba8a317a4b0c2910e6 to your computer and use it in GitHub Desktop.
Basic example of how to use Flamelink within a Firebase Cloud Function
This file contains 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 flamelink = require('flamelink') | |
const admin = require('firebase-admin'); | |
const firebaseApp = admin.initializeApp(functions.config().firebase); | |
const app = flamelink({ firebaseApp, isAdminApp: true }); | |
exports.addMessage = functions.https.onRequest((req, res) => { | |
return app.content.get('messages') | |
.then(messages => { | |
return res.status(200).json({ messages }); | |
}) | |
.catch(error => { | |
res.status(500).json({error}); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment