diff --git a/.firebaserc b/.firebaserc new file mode 100644 index 0000000..b29f907 --- /dev/null +++ b/.firebaserc @@ -0,0 +1,5 @@ +{ + "projects": { + "default": "exopen-c2af4" + } +} diff --git a/database.rules.json b/database.rules.json new file mode 100644 index 0000000..d2b8268 --- /dev/null +++ b/database.rules.json @@ -0,0 +1,6 @@ +{ + "rules": { + ".read": true, + ".write": true + } +} diff --git a/firebase.json b/firebase.json new file mode 100644 index 0000000..dfebb86 --- /dev/null +++ b/firebase.json @@ -0,0 +1,19 @@ +{ + "database": { + "rules": "database.rules.json" + }, + "hosting": { + "public": "build", + "ignore": [ + "firebase.json", + "**/.*", + "**/node_modules/**" + ], + "rewrites": [ + { + "source": "**", + "destination": "/index.html" + } + ] + } +} diff --git a/src/firebase/context.js b/src/firebase/context.js new file mode 100644 index 0000000..3735756 --- /dev/null +++ b/src/firebase/context.js @@ -0,0 +1,11 @@ +import React from 'react'; + +const FirebaseContext = React.createContext(null); + +export const withFirebase = Component => props => ( + + { firebase => } + +); + +export default FirebaseContext; \ No newline at end of file diff --git a/src/firebase/firebase.js b/src/firebase/firebase.js new file mode 100644 index 0000000..3872f7e --- /dev/null +++ b/src/firebase/firebase.js @@ -0,0 +1,35 @@ +import app from 'firebase/app'; +import 'firebase/database'; + +const config = { + apiKey: "AIzaSyCvwmNhhs-1PEF9Qk1gOYNpp-m65-0JJNY", + authDomain: "exopen-c2af4.firebaseapp.com", + databaseURL: "https://exopen-c2af4.firebaseio.com", + projectId: "exopen-c2af4", + storageBucket: "exopen-c2af4.appspot.com", + messagingSenderId: "1003479661787" +}; + +class Firebase { + constructor() { + app.initializeApp(config); + + this.db = app.database(); + this.auth = app.auth(); + } + + // *** Auth API *** + createUserWithEmailAndPassword = (email, password) => + this.auth.createUserWithEmailAndPassword(email, password); + + signInWithEmailAndPassword = (email, password) => + this.auth.signInWithEmailAndPassword(email, password); + + signOut = () => this.auth.signOut(); + + sendPasswordResetEmail = email => this.auth.sendPasswordResetEmail(email); + + updatePassword = password => this.auth.currentUser.updatePassword(password); +} + +export default Firebase; \ No newline at end of file diff --git a/src/firebase/index.js b/src/firebase/index.js new file mode 100644 index 0000000..ae5aa2f --- /dev/null +++ b/src/firebase/index.js @@ -0,0 +1,6 @@ +import Firebase from './firebase'; +import FirebaseContext from './context'; + +export default Firebase; + +export { FirebaseContext }; \ No newline at end of file diff --git a/src/index.js b/src/index.js index 5f6ae24..3b163ef 100644 --- a/src/index.js +++ b/src/index.js @@ -2,11 +2,16 @@ import React from 'react'; import ReactDOM from 'react-dom'; import './index.css'; import App from './components/App'; -import * as serviceWorker from './serviceWorker'; +// import * as serviceWorker from './serviceWorker'; +import Firebase, { FirebaseContext } from './firebase'; -ReactDOM.render(, document.getElementById('root')); +ReactDOM.render( + + + , + document.getElementById('root')); // If you want your app to work offline and load faster, you can change // unregister() to register() below. Note this comes with some pitfalls. // Learn more about service workers: https://bit.ly/CRA-PWA -serviceWorker.unregister(); +// serviceWorker.unregister();