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
service: myService | |
## define some static variables | |
custom: | |
writeModelTableName: commitsByEntityIdAndVersion | |
writeModelIndexName: indexByEntityNameAndCommitId | |
readModelDomainName: readmodel | |
provider: | |
name: aws |
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 events = [ | |
{ type: 'TodoAdded', title: 'Learn CQRS' }, | |
{ type: 'TodoAdded', title: 'Save the world' }, | |
{ type: 'TodoCompleted', index: 0 }, | |
{ type: 'TodoRemoved', index: 1 }, | |
] |
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 reducer = (state, event) => { | |
switch (event.type) { | |
case 'TodoAdded': | |
// append event to the list of existing events. | |
return [ | |
...state, | |
{ title: event.title, completed: false }, | |
] | |
case 'TodoRemoved': |
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
{ | |
"rules": { | |
"messages": { | |
"$roomId": { | |
// users can only chat in their own private room. admins can chat anywhere. | |
".read": "$roomId === auth.uid || auth.token.admin === true", | |
"$messageId": { | |
// can only write new data, not modify old | |
".write": "($roomId === auth.uid || auth.token.admin === true) && !data.exists() && newData.exists()", | |
// must contain only userId and body |
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 admin = require('firebase-admin') | |
const fetch = require('node-fetch') | |
admin.initializeApp(functions.config().firebase) | |
// create an authentication endpoint. | |
// calls our backend to validate JWT | |
// if it passes, generate firebase token for the user | |
module.exports.authenticate = functions.https | |
.onRequest((req, res) => { |