Skip to content

Instantly share code, notes, and snippets.

View georgesboris's full-sized avatar

georges boris georgesboris

  • uncover.co
  • Fortaleza, Brasil
  • 06:18 (UTC -03:00)
  • X @georgesboris
View GitHub Profile
@georgesboris
georgesboris / owners.rules.js
Last active October 23, 2017 18:23
firebase-app - rules - owners
module.exports = {
__setup__: 'owners',
// anyone can read our posts logs
post: true
};
@georgesboris
georgesboris / paths.rules.js
Last active October 17, 2017 12:08
firebase-app - rules - paths
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: ... }
@georgesboris
georgesboris / app.js
Last active October 17, 2017 12:06
firebase-app - putting it together 2
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)
@georgesboris
georgesboris / firebase-app.js
Last active October 17, 2017 12:05
firebase-app - putting it together
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 }) };
@georgesboris
georgesboris / actions.js
Created October 16, 2017 15:56
firebase-app - action with owner
const { postBody } = require('../paths/paths');
module.exports = {
updatePost: {
id: 'updatePost',
log: ['post'],
validate: ['value'],
updates: ({ postId, value }) => ({
[postBody(postId)]: value
@georgesboris
georgesboris / owners.js
Last active October 16, 2017 20:45
firebase-app - owners
module.exports = {
'post': 'postId'
};
@georgesboris
georgesboris / actions.js
Last active October 16, 2017 21:23
firebase-app simple action
const paths = require('../paths/paths');
module.exports = {
createPost: {
id: 'createPost',
create: ['postId'],
validate: ['title', 'body'],
updates: (payload, helpers) => ({
[paths.post(payload.postId)]: {
@georgesboris
georgesboris / paths.js
Last active October 16, 2017 21:21
firebase-app - paths
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`,
};
@georgesboris
georgesboris / phaser-webpack.md
Last active June 22, 2017 16:09
Phaser simple webpack setup

Using Phaser with Webpack

Using phaser with ES6, npm modules and whatnot is actually quite simple.

First, install the needed dependencies.

npm install -S expose-loader phaser-ce
@georgesboris
georgesboris / index.js
Created June 14, 2017 19:35
blank firebase functions
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;