mirror of
https://github.com/jlengrand/undercover.git
synced 2026-03-10 08:51:23 +00:00
chore: add firebase setup
This commit is contained in:
3
.firebase/hosting.ZGlzdA.cache
Normal file
3
.firebase/hosting.ZGlzdA.cache
Normal file
@@ -0,0 +1,3 @@
|
||||
index.html,1560533560462,fa9408ee2ea0507f332000434f6fb46e19a32119d1f1e02ab7dc25468ef9368e
|
||||
under-cover.js,1560533560470,bb1e24b7a2a350e3fc658379f8310fc693225f0d226f796a6d08194eb2a0481b
|
||||
under-cover.js.map,1560533560469,a8ad9bee1c45a5d158042cc5500dd84aba0d7eb2f1acf5d47c37c9b4fd59b15f
|
||||
5
.firebaserc
Normal file
5
.firebaserc
Normal file
@@ -0,0 +1,5 @@
|
||||
{
|
||||
"projects": {
|
||||
"default": "undercover-1"
|
||||
}
|
||||
}
|
||||
2
.gitignore
vendored
2
.gitignore
vendored
@@ -1 +1,3 @@
|
||||
node_modules
|
||||
firebase-debug.log
|
||||
dist
|
||||
6
database.rules.json
Normal file
6
database.rules.json
Normal file
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"rules": {
|
||||
".read": "auth != null",
|
||||
".write": "auth != null"
|
||||
}
|
||||
}
|
||||
26
firebase.json
Normal file
26
firebase.json
Normal file
@@ -0,0 +1,26 @@
|
||||
{
|
||||
"firestore": {
|
||||
"rules": "firestore.rules",
|
||||
"indexes": "firestore.indexes.json"
|
||||
},
|
||||
"functions": {
|
||||
"predeploy": [
|
||||
"npm --prefix \"$RESOURCE_DIR\" run lint"
|
||||
],
|
||||
"source": "functions"
|
||||
},
|
||||
"hosting": {
|
||||
"public": "dist",
|
||||
"ignore": [
|
||||
"firebase.json",
|
||||
"**/.*",
|
||||
"**/node_modules/**"
|
||||
]
|
||||
},
|
||||
"storage": {
|
||||
"rules": "storage.rules"
|
||||
},
|
||||
"database": {
|
||||
"rules": "database.rules.json"
|
||||
}
|
||||
}
|
||||
26
firestore.indexes.json
Normal file
26
firestore.indexes.json
Normal file
@@ -0,0 +1,26 @@
|
||||
{
|
||||
// Example:
|
||||
//
|
||||
// "indexes": [
|
||||
// {
|
||||
// "collectionGroup": "widgets",
|
||||
// "queryScope": "COLLECTION",
|
||||
// "fields": [
|
||||
// { "fieldPath": "foo", "arrayConfig": "CONTAINS" },
|
||||
// { "fieldPath": "bar", "mode": "DESCENDING" }
|
||||
// ]
|
||||
// },
|
||||
//
|
||||
// "fieldOverrides": [
|
||||
// {
|
||||
// "collectionGroup": "widgets",
|
||||
// "fieldPath": "baz",
|
||||
// "indexes": [
|
||||
// { "order": "ASCENDING", "queryScope": "COLLECTION" }
|
||||
// ]
|
||||
// },
|
||||
// ]
|
||||
// ]
|
||||
"indexes": [],
|
||||
"fieldOverrides": []
|
||||
}
|
||||
7
firestore.rules
Normal file
7
firestore.rules
Normal file
@@ -0,0 +1,7 @@
|
||||
service cloud.firestore {
|
||||
match /databases/{database}/documents {
|
||||
match /{document=**} {
|
||||
allow read, write;
|
||||
}
|
||||
}
|
||||
}
|
||||
123
functions/.eslintrc.json
Normal file
123
functions/.eslintrc.json
Normal file
@@ -0,0 +1,123 @@
|
||||
{
|
||||
"parserOptions": {
|
||||
// Required for certain syntax usages
|
||||
"ecmaVersion": 2017
|
||||
},
|
||||
"plugins": [
|
||||
"promise"
|
||||
],
|
||||
"extends": "eslint:recommended",
|
||||
"rules": {
|
||||
// Removed rule "disallow the use of console" from recommended eslint rules
|
||||
"no-console": "off",
|
||||
|
||||
// Removed rule "disallow multiple spaces in regular expressions" from recommended eslint rules
|
||||
"no-regex-spaces": "off",
|
||||
|
||||
// Removed rule "disallow the use of debugger" from recommended eslint rules
|
||||
"no-debugger": "off",
|
||||
|
||||
// Removed rule "disallow unused variables" from recommended eslint rules
|
||||
"no-unused-vars": "off",
|
||||
|
||||
// Removed rule "disallow mixed spaces and tabs for indentation" from recommended eslint rules
|
||||
"no-mixed-spaces-and-tabs": "off",
|
||||
|
||||
// Removed rule "disallow the use of undeclared variables unless mentioned in /*global */ comments" from recommended eslint rules
|
||||
"no-undef": "off",
|
||||
|
||||
// Warn against template literal placeholder syntax in regular strings
|
||||
"no-template-curly-in-string": 1,
|
||||
|
||||
// Warn if return statements do not either always or never specify values
|
||||
"consistent-return": 1,
|
||||
|
||||
// Warn if no return statements in callbacks of array methods
|
||||
"array-callback-return": 1,
|
||||
|
||||
// Require the use of === and !==
|
||||
"eqeqeq": 2,
|
||||
|
||||
// Disallow the use of alert, confirm, and prompt
|
||||
"no-alert": 2,
|
||||
|
||||
// Disallow the use of arguments.caller or arguments.callee
|
||||
"no-caller": 2,
|
||||
|
||||
// Disallow null comparisons without type-checking operators
|
||||
"no-eq-null": 2,
|
||||
|
||||
// Disallow the use of eval()
|
||||
"no-eval": 2,
|
||||
|
||||
// Warn against extending native types
|
||||
"no-extend-native": 1,
|
||||
|
||||
// Warn against unnecessary calls to .bind()
|
||||
"no-extra-bind": 1,
|
||||
|
||||
// Warn against unnecessary labels
|
||||
"no-extra-label": 1,
|
||||
|
||||
// Disallow leading or trailing decimal points in numeric literals
|
||||
"no-floating-decimal": 2,
|
||||
|
||||
// Warn against shorthand type conversions
|
||||
"no-implicit-coercion": 1,
|
||||
|
||||
// Warn against function declarations and expressions inside loop statements
|
||||
"no-loop-func": 1,
|
||||
|
||||
// Disallow new operators with the Function object
|
||||
"no-new-func": 2,
|
||||
|
||||
// Warn against new operators with the String, Number, and Boolean objects
|
||||
"no-new-wrappers": 1,
|
||||
|
||||
// Disallow throwing literals as exceptions
|
||||
"no-throw-literal": 2,
|
||||
|
||||
// Require using Error objects as Promise rejection reasons
|
||||
"prefer-promise-reject-errors": 2,
|
||||
|
||||
// Enforce “for” loop update clause moving the counter in the right direction
|
||||
"for-direction": 2,
|
||||
|
||||
// Enforce return statements in getters
|
||||
"getter-return": 2,
|
||||
|
||||
// Disallow await inside of loops
|
||||
"no-await-in-loop": 2,
|
||||
|
||||
// Disallow comparing against -0
|
||||
"no-compare-neg-zero": 2,
|
||||
|
||||
// Warn against catch clause parameters from shadowing variables in the outer scope
|
||||
"no-catch-shadow": 1,
|
||||
|
||||
// Disallow identifiers from shadowing restricted names
|
||||
"no-shadow-restricted-names": 2,
|
||||
|
||||
// Enforce return statements in callbacks of array methods
|
||||
"callback-return": 2,
|
||||
|
||||
// Require error handling in callbacks
|
||||
"handle-callback-err": 2,
|
||||
|
||||
// Warn against string concatenation with __dirname and __filename
|
||||
"no-path-concat": 1,
|
||||
|
||||
// Prefer using arrow functions for callbacks
|
||||
"prefer-arrow-callback": 1,
|
||||
|
||||
// Return inside each then() to create readable and reusable Promise chains.
|
||||
// Forces developers to return console logs and http calls in promises.
|
||||
"promise/always-return": 2,
|
||||
|
||||
//Enforces the use of catch() on un-returned promises
|
||||
"promise/catch-or-return": 2,
|
||||
|
||||
// Warn against nested then() or catch() statements
|
||||
"promise/no-nesting": 1
|
||||
}
|
||||
}
|
||||
2
functions/.gitignore
vendored
Normal file
2
functions/.gitignore
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
node_modules/
|
||||
.firebase
|
||||
8
functions/index.js
Normal file
8
functions/index.js
Normal file
@@ -0,0 +1,8 @@
|
||||
const functions = require('firebase-functions');
|
||||
|
||||
// // Create and Deploy Your First Cloud Functions
|
||||
// // https://firebase.google.com/docs/functions/write-firebase-functions
|
||||
//
|
||||
// exports.helloWorld = functions.https.onRequest((request, response) => {
|
||||
// response.send("Hello from Firebase!");
|
||||
// });
|
||||
25
functions/package.json
Normal file
25
functions/package.json
Normal file
@@ -0,0 +1,25 @@
|
||||
{
|
||||
"name": "functions",
|
||||
"description": "Cloud Functions for Firebase",
|
||||
"scripts": {
|
||||
"lint": "eslint .",
|
||||
"serve": "firebase serve --only functions",
|
||||
"shell": "firebase functions:shell",
|
||||
"start": "npm run shell",
|
||||
"deploy": "firebase deploy --only functions",
|
||||
"logs": "firebase functions:log"
|
||||
},
|
||||
"engines": {
|
||||
"node": "8"
|
||||
},
|
||||
"dependencies": {
|
||||
"firebase-admin": "^8.0.0",
|
||||
"firebase-functions": "^3.0.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"eslint": "^5.12.0",
|
||||
"eslint-plugin-promise": "^4.0.1",
|
||||
"firebase-functions-test": "^0.1.6"
|
||||
},
|
||||
"private": true
|
||||
}
|
||||
65
index.html.firebase
Normal file
65
index.html.firebase
Normal file
@@ -0,0 +1,65 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<title>Welcome to Firebase Hosting</title>
|
||||
|
||||
<!-- update the version number as needed -->
|
||||
<script defer src="/__/firebase/6.2.0/firebase-app.js"></script>
|
||||
<!-- include only the Firebase features as you need -->
|
||||
<script defer src="/__/firebase/6.2.0/firebase-auth.js"></script>
|
||||
<script defer src="/__/firebase/6.2.0/firebase-database.js"></script>
|
||||
<script defer src="/__/firebase/6.2.0/firebase-messaging.js"></script>
|
||||
<script defer src="/__/firebase/6.2.0/firebase-storage.js"></script>
|
||||
<!-- initialize the SDK after all desired features are loaded -->
|
||||
<script defer src="/__/firebase/init.js"></script>
|
||||
|
||||
<style media="screen">
|
||||
body { background: #ECEFF1; color: rgba(0,0,0,0.87); font-family: Roboto, Helvetica, Arial, sans-serif; margin: 0; padding: 0; }
|
||||
#message { background: white; max-width: 360px; margin: 100px auto 16px; padding: 32px 24px; border-radius: 3px; }
|
||||
#message h2 { color: #ffa100; font-weight: bold; font-size: 16px; margin: 0 0 8px; }
|
||||
#message h1 { font-size: 22px; font-weight: 300; color: rgba(0,0,0,0.6); margin: 0 0 16px;}
|
||||
#message p { line-height: 140%; margin: 16px 0 24px; font-size: 14px; }
|
||||
#message a { display: block; text-align: center; background: #039be5; text-transform: uppercase; text-decoration: none; color: white; padding: 16px; border-radius: 4px; }
|
||||
#message, #message a { box-shadow: 0 1px 3px rgba(0,0,0,0.12), 0 1px 2px rgba(0,0,0,0.24); }
|
||||
#load { color: rgba(0,0,0,0.4); text-align: center; font-size: 13px; }
|
||||
@media (max-width: 600px) {
|
||||
body, #message { margin-top: 0; background: white; box-shadow: none; }
|
||||
body { border-top: 16px solid #ffa100; }
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div id="message">
|
||||
<h2>Welcome</h2>
|
||||
<h1>Firebase Hosting Setup Complete</h1>
|
||||
<p>You're seeing this because you've successfully setup Firebase Hosting. Now it's time to go build something extraordinary!</p>
|
||||
<a target="_blank" href="https://firebase.google.com/docs/hosting/">Open Hosting Documentation</a>
|
||||
</div>
|
||||
<p id="load">Firebase SDK Loading…</p>
|
||||
|
||||
<script>
|
||||
document.addEventListener('DOMContentLoaded', function() {
|
||||
// // 🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥
|
||||
// // The Firebase SDK is initialized and available here!
|
||||
//
|
||||
// firebase.auth().onAuthStateChanged(user => { });
|
||||
// firebase.database().ref('/path/to/ref').on('value', snapshot => { });
|
||||
// firebase.messaging().requestPermission().then(() => { });
|
||||
// firebase.storage().ref('/path/to/ref').getDownloadURL().then(() => { });
|
||||
//
|
||||
// // 🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥
|
||||
|
||||
try {
|
||||
let app = firebase.app();
|
||||
let features = ['auth', 'database', 'messaging', 'storage'].filter(feature => typeof app[feature] === 'function');
|
||||
document.getElementById('load').innerHTML = `Firebase SDK loaded with ${features.join(', ')}`;
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
document.getElementById('load').innerHTML = 'Error loading the Firebase SDK, check the console.';
|
||||
}
|
||||
});
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
7
storage.rules
Normal file
7
storage.rules
Normal file
@@ -0,0 +1,7 @@
|
||||
service firebase.storage {
|
||||
match /b/{bucket}/o {
|
||||
match /{allPaths=**} {
|
||||
allow read, write: if request.auth!=null;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user