Giter Club home page Giter Club logo

revents's Introduction

Re-vents App

An exercise followed from Neil Cummings' React, Redux and Firestore course. It turns out to a social event app.

Installation notes

Since I have excluded the API key, the project won't work directly as you install it. You need to create three files: env.js, keys.js, and firebase.js

About env.js

This file should be in the /public/ folder. It will have the following code:

const googleMaps = document.getElementById('googleMaps')

googleMaps.src = 'https://maps.googleapis.com/maps/api/js?key=YOUR_API_KEY_HERE&libraries=places'

Change the YOUR_API_KEY_HERE part with your actual API key.

About keys.js

This file should be in the /src/app/config/ folder. It will have the following code:

export const GOOGLE_MAPS = 'YOUR_API_KEY_HERE'

Change the YOUR_API_KEY_HERE part with your actual API key.

About firebase.js

This file should be in the /src/app/config/ folder. It will have the following code:

import firebase from 'firebase/app'
import 'firebase/firestore'
import 'firebase/database'
import 'firebase/auth'
import 'firebase/storage'

const firebaseConfig = {
    apiKey: "YOUR_API_KEY_HERE",
    authDomain: "YOUR_AUTH_DOMAIN_HERE",
    projectId: "YOUR_PROJECT_ID_HERE",
    storageBucket: "YOUR_STORAGE_BUCKET_HERE",
    messagingSenderId: "YOUR_MESSAGING_SENDER_ID",
    appId: "YOUR_APP_ID"
}

firebase.initializeApp(firebaseConfig)
firebase.firestore()

export default firebase

Change the strings with your actual app credentials. You can obtain them from the project settings.

Firestore rules

The following rules are applied to the Firestore database:

rules_version = '2';
service cloud.firestore {
  match /databases/{database}/documents {
    match /users/{userId} {
    	allow read: if isSignedIn();
      allow update, create: if request.auth.uid == userId;
      match /photos/{document=**} {
      	allow read: if isSignedIn();
        allow write: if request.auth.uid == userId;
      }
    }
    match /following/{userId}/{document=**} {
    	allow read: if isSignedIn();
      allow write: if request.auth.uid == userId;
      allow update: if resource.id == request.auth.uid;
    }
    match /events/{document=**} {
    	allow read, list;
      allow update: if isHost();
      allow update: if isSignedIn() && updateAttendeeFieldsOnly();
      allow create: if isSignedIn();
    }
  }
}

function isSignedIn() {
	return request.auth.uid != null;
}

function isHost() {
	return isSignedIn() && resource.data.hostUid == request.auth.uid;
}

function updateAttendeeFieldsOnly() {
	return incomingData().diff(existingData()).changedKeys().hasOnly(['attendeeIds', 'attendees'])
}

function existingData() {
	return resource.data;
}

function incomingData() {
	return request.resource.data;
}

revents's People

Contributors

aademirci avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.