Using phaser with ES6, npm modules and whatnot is actually quite simple.
First, install the needed dependencies.
npm install -S expose-loader phaser-ce
const paths = require('./paths') | |
const { validate, newData, isAuth, isAuthId, isString, isNow } = require('firebase-rules/helpers/common'); | |
module.exports = { | |
__setup__: 'paths', | |
// this is a shorthand for { read: 'auth.uid != null' } | |
[paths.posts]: isAuth, | |
// these are shorthands for { validate: ... } |
const { actions, executeAction } = require('./src/firebase-app'); | |
const { updatePost } = actions; | |
const actionPayload = { | |
postId: 'post_123', | |
value: 'Post body with adjustments' | |
}; | |
executeAction(updatePost, actionPayload) | |
.then(displaySuccess) |
const firebase = require('firebase'); | |
firebase.initializeApp(config); | |
const getHelpers = require('firebase-app'); | |
const owners = require('./owners/owners'); | |
const actions = require('./actions/actions'); | |
const paths = require('./paths/paths'); | |
module.exports = { actions, paths, ...getHelpers({ firebase, owners }) }; |
const { postBody } = require('../paths/paths'); | |
module.exports = { | |
updatePost: { | |
id: 'updatePost', | |
log: ['post'], | |
validate: ['value'], | |
updates: ({ postId, value }) => ({ | |
[postBody(postId)]: value |
module.exports = { | |
'post': 'postId' | |
}; |
const paths = require('../paths/paths'); | |
module.exports = { | |
createPost: { | |
id: 'createPost', | |
create: ['postId'], | |
validate: ['title', 'body'], | |
updates: (payload, helpers) => ({ | |
[paths.post(payload.postId)]: { |
module.exports = { | |
posts: 'posts', | |
post: postId => `posts/${postId}`, | |
postTitle: postId => `posts/${postId}/title`, | |
postBody: postId => `posts/${postId}/body`, | |
postCreatedAt: postId => `posts/${postId}/createdAt`, | |
postCreatedBy: postId => `posts/${postId}/createdBy`, | |
}; |
const { firebase, functions } = require('./lib/firebase'); | |
const times = require('lodash/times'); | |
const myFunctions = times(33).map((i) => ({ | |
key: `fnName_${i}`, | |
watcher: functions.database.ref('my-db').onWrite(() => {}) | |
})); | |
myFunctions.forEach((fn) => { | |
exports[fn.key] = fn.watcher; |
/** | |
* Require all functions files. | |
* /src/{function}/{function}.js | |
* | |
* functions must export | |
* { | |
* key: string the name of the function, | |
* watcher: fn the firebase-function watcher function | |
* } | |
* |