Skip to content

Commit

Permalink
completed firebase initiation
Browse files Browse the repository at this point in the history
  • Loading branch information
teetangh committed Jun 6, 2023
1 parent ef53ad1 commit 14afc02
Show file tree
Hide file tree
Showing 6 changed files with 82 additions and 20 deletions.
5 changes: 5 additions & 0 deletions .firebaserc
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"projects": {
"default": "noteups-web-original-backend"
}
}
35 changes: 35 additions & 0 deletions firebase.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
{
"functions": [
{
"source": "functions",
"codebase": "default",
"ignore": [
"node_modules",
".git",
"firebase-debug.log",
"firebase-debug.*.log"
],
"predeploy": [
"npm --prefix \"$RESOURCE_DIR\" run lint"
]
}
],
"database": {
"rules": "database.rules.json"
},
"firestore": {
"rules": "firestore.rules",
"indexes": "firestore.indexes.json"
},
"hosting": {
"public": "public",
"ignore": [
"firebase.json",
"**/.*",
"**/node_modules/**"
]
},
"storage": {
"rules": "storage.rules"
}
}
22 changes: 16 additions & 6 deletions functions/index.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,19 @@
const functions = require("firebase-functions");
/**
* Import function triggers from their respective submodules:
*
* const {onCall} = require("firebase-functions/v2/https");
* const {onDocumentWritten} = require("firebase-functions/v2/firestore");
*
* See a full list of supported triggers at https://firebase.google.com/docs/functions
*/

// // Create and deploy your first functions
// // https://firebase.google.com/docs/functions/get-started
//
// exports.helloWorld = functions.https.onRequest((request, response) => {
// functions.logger.info("Hello logs!", {structuredData: true});
const {onRequest} = require("firebase-functions/v2/https");
const logger = require("firebase-functions/logger");

// Create and deploy your first functions
// https://firebase.google.com/docs/functions/get-started

// exports.helloWorld = onRequest((request, response) => {
// logger.info("Hello logs!", {structuredData: true});
// response.send("Hello from Firebase!");
// });
8 changes: 4 additions & 4 deletions functions/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,17 @@
"logs": "firebase functions:log"
},
"engines": {
"node": "16"
"node": "18"
},
"main": "index.js",
"dependencies": {
"firebase-admin": "^11.5.0",
"firebase-functions": "^4.2.0"
"firebase-admin": "^11.8.0",
"firebase-functions": "^4.3.1"
},
"devDependencies": {
"eslint": "^8.15.0",
"eslint-config-google": "^0.14.0",
"firebase-functions-test": "^3.0.0"
"firebase-functions-test": "^3.1.0"
},
"private": true
}
20 changes: 10 additions & 10 deletions public/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,17 @@
<title>Welcome to Firebase Hosting</title>

<!-- update the version number as needed -->
<script defer src="/__/firebase/9.19.1/firebase-app-compat.js"></script>
<script defer src="/__/firebase/9.22.1/firebase-app-compat.js"></script>
<!-- include only the Firebase features as you need -->
<script defer src="/__/firebase/9.19.1/firebase-auth-compat.js"></script>
<script defer src="/__/firebase/9.19.1/firebase-database-compat.js"></script>
<script defer src="/__/firebase/9.19.1/firebase-firestore-compat.js"></script>
<script defer src="/__/firebase/9.19.1/firebase-functions-compat.js"></script>
<script defer src="/__/firebase/9.19.1/firebase-messaging-compat.js"></script>
<script defer src="/__/firebase/9.19.1/firebase-storage-compat.js"></script>
<script defer src="/__/firebase/9.19.1/firebase-analytics-compat.js"></script>
<script defer src="/__/firebase/9.19.1/firebase-remote-config-compat.js"></script>
<script defer src="/__/firebase/9.19.1/firebase-performance-compat.js"></script>
<script defer src="/__/firebase/9.22.1/firebase-auth-compat.js"></script>
<script defer src="/__/firebase/9.22.1/firebase-database-compat.js"></script>
<script defer src="/__/firebase/9.22.1/firebase-firestore-compat.js"></script>
<script defer src="/__/firebase/9.22.1/firebase-functions-compat.js"></script>
<script defer src="/__/firebase/9.22.1/firebase-messaging-compat.js"></script>
<script defer src="/__/firebase/9.22.1/firebase-storage-compat.js"></script>
<script defer src="/__/firebase/9.22.1/firebase-analytics-compat.js"></script>
<script defer src="/__/firebase/9.22.1/firebase-remote-config-compat.js"></script>
<script defer src="/__/firebase/9.22.1/firebase-performance-compat.js"></script>
<!--
initialize the SDK after all desired features are loaded, set useEmulator to false
to avoid connecting the SDK to running emulators.
Expand Down
12 changes: 12 additions & 0 deletions storage.rules
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
rules_version = '2';

// Craft rules based on data in your Firestore database
// allow write: if firestore.get(
// /databases/(default)/documents/users/$(request.auth.uid)).data.isAdmin;
service firebase.storage {
match /b/{bucket}/o {
match /{allPaths=**} {
allow read, write: if false;
}
}
}

0 comments on commit 14afc02

Please sign in to comment.