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
import * as functions from 'firebase-functions'; | |
import * as admin from 'firebase-admin'; | |
admin.initializeApp(); | |
const firestore = admin.firestore(); | |
export const sendCryptoAlerts = functions.firestore.document('prices/{currency}') | |
.onUpdate(async (change, context) => { | |
const currencyId: string = context.params.currency; | |
const data = change.after.data(); |
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
import ( | |
"context" | |
"cloud.google.com/go/firestore" | |
firebase "firebase.google.com/go" | |
) | |
// FirebaseClient is a helper for interacting with Firebase services. | |
type FirebaseClient struct { | |
db *firestore.Client |
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
package scorer | |
import ( | |
"context" | |
"log" | |
"time" | |
firebase "firebase.google.com/go" | |
"firebase.google.com/go/db" | |
) |
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
func ScoreReview(ctx context.Context, e FirestoreEvent) error { | |
review := e.Value.Fields | |
reviweScore := score(review.Text.Value) | |
ref := client.NewRef("scores").Child(review.Author.Value) | |
updateTxn := func(node db.TransactionNode) (interface{}, error) { | |
var currentScore int | |
if err := node.Unmarshal(¤tScore); err != nil { | |
return nil, err | |
} |
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 admin = require('firebase-admin'); | |
(async () => { | |
admin.initializeApp(); | |
const message = { | |
data: { | |
time: '1:15 PM', | |
symbol: 'GOOG', | |
value: '1184.46' |
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
(async () => { | |
admin.initializeApp(); | |
const message = { | |
data: { | |
time: '1:15 PM', | |
symbol: 'GOOG', | |
value: '1184.46' | |
}, | |
tokens: [token1, token2, /* up to 100 tokens... */], |
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 messages = []; | |
messages.push({ | |
notification: { | |
title: 'Good morning Alice', | |
body: 'The weather in your area is nice and sunny today.', | |
}, | |
token: token1, | |
}); | |
messages.push({ | |
notification: { |
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
function getMessages(count) { | |
const messages = []; | |
for (let i = 0; i < count; i++) { | |
messages.push({ | |
topic: `test-topic-${i % 10}`, | |
}); | |
} | |
return messages; | |
} |
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 user = firebase.auth().currentUser; | |
user.sendEmailVerification().then(function() { | |
displayHomePage(); | |
}).catch(function(error) { | |
displayError(error); | |
}); |
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
import * as admin from 'firebase-admin'; | |
import * as functions from 'firebase-functions'; | |
import * as sendgrid from '@sendgrid/mail'; | |
admin.initializeApp(); | |
export const sendEmailVerification = functions.auth.user().onCreate( | |
async (user: admin.auth.UserRecord, context: functions.EventContext) => { | |
const email = user.email; | |
const link = await admin.auth().generateEmailVerificationLink(email, { |