Skip to content

Commit

Permalink
feat: Rewrite
Browse files Browse the repository at this point in the history
  • Loading branch information
bharatkashyap committed Jan 11, 2024
1 parent 24527ff commit ee83135
Show file tree
Hide file tree
Showing 12 changed files with 1,371 additions and 393 deletions.
19 changes: 19 additions & 0 deletions .github/workflows/firebase-hosting-merge.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# This file was auto-generated by the Firebase CLI
# https://github.com/firebase/firebase-tools

name: Deploy to Firebase Hosting on merge
'on':
push:
branches:
- master
jobs:
build_and_deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: FirebaseExtended/action-hosting-deploy@v0
with:
repoToken: '${{ secrets.GITHUB_TOKEN }}'
firebaseServiceAccount: '${{ secrets.FIREBASE_SERVICE_ACCOUNT_QUIZGEN_FINAL }}'
channelId: live
projectId: quizgen-final
16 changes: 16 additions & 0 deletions .github/workflows/firebase-hosting-pull-request.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# This file was auto-generated by the Firebase CLI
# https://github.com/firebase/firebase-tools

name: Deploy to Firebase Hosting on PR
'on': pull_request
jobs:
build_and_preview:
if: '${{ github.event.pull_request.head.repo.full_name == github.repository }}'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: FirebaseExtended/action-hosting-deploy@v0
with:
repoToken: '${{ secrets.GITHUB_TOKEN }}'
firebaseServiceAccount: '${{ secrets.FIREBASE_SERVICE_ACCOUNT_QUIZGEN_FINAL }}'
projectId: quizgen-final
66 changes: 66 additions & 0 deletions final/public/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
firebase-debug.log*
firebase-debug.*.log*

# Firebase cache
.firebase/

# Firebase config

# Uncomment this if you'd like others to create their own Firebase project.
# For a team working on the same Firebase project(s), it is recommended to leave
# it commented so all members can deploy to the same project(s) in .firebaserc.
# .firebaserc

# Runtime data
pids
*.pid
*.seed
*.pid.lock

# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov

# Coverage directory used by tools like istanbul
coverage

# nyc test coverage
.nyc_output

# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
.grunt

# Bower dependency directory (https://bower.io/)
bower_components

# node-waf configuration
.lock-wscript

# Compiled binary addons (http://nodejs.org/api/addons.html)
build/Release

# Dependency directories
node_modules/

# Optional npm cache directory
.npm

# Optional eslint cache
.eslintcache

# Optional REPL history
.node_repl_history

# Output of 'npm pack'
*.tgz

# Yarn Integrity file
.yarn-integrity

# dotenv environment variables file
.env
49 changes: 49 additions & 0 deletions final/public/firebase.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
import { initializeApp } from "https://www.gstatic.com/firebasejs/10.7.1/firebase-app.js";

import {
getFirestore,
collection as firestoreCollection,
query as firestoreQuery,
where as firestoreWhere,
getDoc as firebaseGetDoc,
getDocs as firebaseGetDocs,
doc as firebaseDoc,
setDoc as firebaseSetDoc,
serverTimestamp as firebaseServerTimestamp,
} from "https://www.gstatic.com/firebasejs/10.7.1/firebase-firestore.js";

import {
getAuth,
signInWithPopup,
GoogleAuthProvider,
} from "https://www.gstatic.com/firebasejs/10.7.1/firebase-auth.js";

const firebaseConfig = {
apiKey: "AIzaSyD0db68DhXLKxtPCyzmjeL3zcWbIllrPU8",
authDomain: "quizgen.app",
databaseURL: "https://quizgen-final.firebaseio.com",
projectId: "quizgen-final",
storageBucket: "quizgen-final.appspot.com",
messagingSenderId: "789815253960",
appId: "1:789815253960:web:8d49a9968c5e7037a47efd",
};
// Initialize Firebase
const app = initializeApp(firebaseConfig);

const provider = new GoogleAuthProvider();
provider.addScope("https://www.googleapis.com/auth/drive.metadata.readonly");
provider.addScope("https://www.googleapis.com/auth/spreadsheets.readonly");

export const GoogleProvider = GoogleAuthProvider;
export const auth = getAuth();
export const signIn = signInWithPopup;
export const googleAuthProvider = provider;
export const setDoc = firebaseSetDoc;
export const doc = firebaseDoc;
export const getDoc = firebaseGetDoc;
export const getDocs = firebaseGetDocs;
export const serverTimestamp = firebaseServerTimestamp;
export const query = firestoreQuery;
export const collection = firestoreCollection;
export const where = firestoreWhere;
export const db = getFirestore(app);
4 changes: 4 additions & 0 deletions final/public/firestore.indexes.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"indexes": [],
"fieldOverrides": []
}
10 changes: 10 additions & 0 deletions final/public/firestore.rules
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
service cloud.firestore {
match /databases/{database}/documents {
// Allow public read access, but only content owners can write
match /quizzes/{id} {
allow read: if true
allow create: if request.auth.uid == request.resource.data.author_uid;
allow update, delete: if request.auth.uid == resource.data.author_uid;
}
}
}
Loading

0 comments on commit ee83135

Please sign in to comment.