Skip to content

Commit

Permalink
Fix use of firebase in JavaScript
Browse files Browse the repository at this point in the history
When I addressing #877, I found these use are different from https://firebase.google.com/docs/web/setup?hl=ja
Looks not effect than before change, but this would be better...
  • Loading branch information
kachick committed Jun 22, 2023
1 parent 8899437 commit a0a353d
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions hashira-web/src/firebase.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { initializeApp } from "firebase/app";
import { FirebaseOptions, initializeApp } from "firebase/app";
import * as auth from "firebase/auth";
import {
addDoc,
Expand All @@ -18,7 +18,7 @@ import {
import * as functions from "firebase/functions";
import { v4 as uuidv4 } from "uuid";

const firebaseConfig = {
const firebaseConfig: FirebaseOptions = {
apiKey: "AIzaSyDMkM3qb_CUokFQDSFemLhPOqXJrR-rVbo",
authDomain: "hashira-web.web.app",
projectId: "hashira-web",
Expand All @@ -28,7 +28,7 @@ const firebaseConfig = {
measurementId: "G-EEZ5MJJ6XL",
};

initializeApp(firebaseConfig);
const app = initializeApp(firebaseConfig);

export const login = () => {
const provider = new auth.GoogleAuthProvider();
Expand All @@ -53,7 +53,7 @@ interface accesstoken {
}

export const claimNewAccessToken = async (uid: string) => {
const db = getFirestore();
const db = getFirestore(app);
const data: accesstoken = {
uid: uid,
accesstoken: uuidv4(),
Expand All @@ -63,7 +63,7 @@ export const claimNewAccessToken = async (uid: string) => {
};

export const fetchAccessTokens = async (uid: string): Promise<string[]> => {
const db = getFirestore();
const db = getFirestore(app);
const querySnapshot = await getDocs(
query(collection(db, "accesstokens"), where("uid", "==", uid)),
);
Expand Down Expand Up @@ -92,7 +92,7 @@ export const revokeAccessTokens = async (
uid: string,
accesstokens: string[],
) => {
const db = getFirestore();
const db = getFirestore(app);

for (const accesstoken of accesstokens) {
const querySnapshot = await getDocs(
Expand Down Expand Up @@ -218,7 +218,7 @@ export const ping = async () => {
};

export const fetchTaskAndPriorities = async (uid: string) => {
const db = getFirestore();
const db = getFirestore(app);
const docRef = doc(db, "tasksAndPriorities", uid);
const docSnapshot = await getDoc(docRef);
return docSnapshot.data() as TasksAndPriorities;
Expand Down

0 comments on commit a0a353d

Please sign in to comment.