Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 35 additions & 0 deletions src/entities/project/project.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import {
addDoc,
collection,
doc,
getDoc,
setDoc,
} from "firebase/firestore/lite";

import { db } from "@shared/firebase/firebase";

export async function getComments() {

Check warning on line 11 in src/entities/project/project.ts

View workflow job for this annotation

GitHub Actions / ci

Missing return type on function

Check warning on line 11 in src/entities/project/project.ts

View workflow job for this annotation

GitHub Actions / ci

Missing return type on function
const docRef = doc(db, "coments", "test");
const docSnap = await getDoc(docRef);

if (!docSnap.exists()) {
console.log("No such document!");
return null;
}

return docSnap.data();
}

export async function updateTitle(newTitle: string) {

Check warning on line 23 in src/entities/project/project.ts

View workflow job for this annotation

GitHub Actions / ci

Missing return type on function

Check warning on line 23 in src/entities/project/project.ts

View workflow job for this annotation

GitHub Actions / ci

Missing return type on function
const docRef = doc(db, "coments", "test");
await setDoc(docRef, { title: newTitle }, { merge: true });
console.log("문서가 새로 작성되거나 덮어쓰기 됐어요.");
}

export async function addPost(title: string) {

Check warning on line 29 in src/entities/project/project.ts

View workflow job for this annotation

GitHub Actions / ci

Missing return type on function

Check warning on line 29 in src/entities/project/project.ts

View workflow job for this annotation

GitHub Actions / ci

Missing return type on function
const postsRef = collection(db, "posts");
const docRef = await addDoc(postsRef, {
title,
});
return docRef.id;
}
15 changes: 15 additions & 0 deletions src/shared/firebase/firebase.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import { initializeApp } from "firebase/app";
import { getFirestore } from "firebase/firestore/lite";

const firebaseConfig = {
apiKey: process.env.REACT_APP_API_KEY,
authDomain: process.env.REACT_APP_AUTH_DOMAIN,
projectId: process.env.REACT_APP_PROJECT_ID,
storageBucket: process.env.REACT_APP_STORAGE_BUCKET,
messagingSenderId: process.env.REACT_APP_MESSAGEINGSENDER_ID,
appId: process.env.REACT_APP_APP_ID,
measurementId: process.env.REACT_APP_MEASUREMENT_ID,
};

const app = initializeApp(firebaseConfig);
export const db = getFirestore(app);
Loading