From 6dbd7c7f612d9adbe4dde5789c00f0dff826c48e Mon Sep 17 00:00:00 2001 From: MurakawaTakuya Date: Wed, 6 Nov 2024 11:57:59 +0900 Subject: [PATCH] ready for deploy --- .gitignore | 7 +++++++ README.md | 26 ++++++++++++++++++++++++++ functions/.eslintrc.js | 3 +-- functions/package-lock.json | 4 ++-- functions/package.json | 4 ++-- functions/src/index.ts | 20 ++++++++++++++------ functions/tsconfig.json | 6 +++--- package-lock.json | 14 ++++++++++++++ package.json | 1 + src/app/firebase.ts | 21 +++++++++++++++++++++ src/app/page.module.scss | 6 ------ 11 files changed, 91 insertions(+), 21 deletions(-) create mode 100644 src/app/firebase.ts diff --git a/.gitignore b/.gitignore index 26b002a..611cfb5 100644 --- a/.gitignore +++ b/.gitignore @@ -38,3 +38,10 @@ yarn-error.log* # typescript *.tsbuildinfo next-env.d.ts + +# Firebase +serviceAccountKey.json +database-debug.log +firestore-debug.log +ui-debug.log +*.cache diff --git a/README.md b/README.md index fa144bb..50ad344 100644 --- a/README.md +++ b/README.md @@ -39,3 +39,29 @@ Check out our [Next.js deployment documentation](https://nextjs.org/docs/app/bui ``` npm install -g firebase-tools ``` + +## Emulate in local +### Frontend +``` +npm run dev +``` + +### Backend +Make sure to build the functions before starting the emulator everytime you make changes to the functions +``` +cd .\functions\ +npm run build +``` + +``` +firebase emulators:start +``` + +## Deploy to Firebase +``` +firebase deploy +``` +if you want to deploy only the functions +``` +firebase deploy --only functions +``` diff --git a/functions/.eslintrc.js b/functions/.eslintrc.js index 338d2b3..ac2bbe7 100644 --- a/functions/.eslintrc.js +++ b/functions/.eslintrc.js @@ -22,11 +22,10 @@ module.exports = { "/lib/**/*", // Ignore built files. "/generated/**/*", // Ignore generated files. ], - plugins: ["@typescript-eslint", "import"], + plugins: ["@typescript-eslint", "import", "eslint-plugin-unused-imports"], rules: { quotes: ["error", "double"], "import/no-unresolved": 0, indent: ["error", 2], }, - plugins: ["eslint-plugin-unused-imports"], }; diff --git a/functions/package-lock.json b/functions/package-lock.json index aef14ba..bcfec90 100644 --- a/functions/package-lock.json +++ b/functions/package-lock.json @@ -6,8 +6,8 @@ "": { "name": "functions", "dependencies": { - "firebase-admin": "^12.6.0", - "firebase-functions": "^6.0.1" + "firebase-admin": "^12.7.0", + "firebase-functions": "^6.1.0" }, "devDependencies": { "@typescript-eslint/eslint-plugin": "^5.12.0", diff --git a/functions/package.json b/functions/package.json index c95a34b..1ee54db 100644 --- a/functions/package.json +++ b/functions/package.json @@ -15,8 +15,8 @@ }, "main": "lib/index.js", "dependencies": { - "firebase-admin": "^12.6.0", - "firebase-functions": "^6.0.1" + "firebase-admin": "^12.7.0", + "firebase-functions": "^6.1.0" }, "devDependencies": { "@typescript-eslint/eslint-plugin": "^5.12.0", diff --git a/functions/src/index.ts b/functions/src/index.ts index 7530fe0..2d5c0d5 100644 --- a/functions/src/index.ts +++ b/functions/src/index.ts @@ -7,13 +7,21 @@ * See a full list of supported triggers at https://firebase.google.com/docs/functions */ -// import { onRequest } from "firebase-functions/v2/https"; -// import * as logger from "firebase-functions/logger"; +import admin, { ServiceAccount } from "firebase-admin"; +import * as logger from "firebase-functions/logger"; +import { onRequest } from "firebase-functions/v2/https"; +import serviceAccount from "./serviceAccountKey.json"; + +admin.initializeApp({ + credential: admin.credential.cert(serviceAccount as ServiceAccount), +}); // Start writing functions // https://firebase.google.com/docs/functions/typescript -// export const helloWorld = onRequest((request, response) => { -// logger.info("Hello logs!", {structuredData: true}); -// response.send("Hello from Firebase!"); -// }); +const region = "asia-northeast1"; + +export const helloWorld = onRequest({ region: region }, (req, res) => { + logger.info("Hello log!", { structuredData: true }); + res.send("Hello World!"); +}); diff --git a/functions/tsconfig.json b/functions/tsconfig.json index 7ce05d0..56c1a18 100644 --- a/functions/tsconfig.json +++ b/functions/tsconfig.json @@ -5,11 +5,11 @@ "noUnusedLocals": true, "outDir": "lib", "sourceMap": true, + "resolveJsonModule": true, "strict": true, + "esModuleInterop": true, "target": "es2017" }, "compileOnSave": true, - "include": [ - "src" - ] + "include": ["src"] } diff --git a/package-lock.json b/package-lock.json index 98f7234..9f767e0 100644 --- a/package-lock.json +++ b/package-lock.json @@ -20,6 +20,7 @@ "@types/react-dom": "^18", "eslint": "^8.57.1", "eslint-config-next": "15.0.2", + "eslint-config-prettier": "^9.1.0", "eslint-plugin-unused-imports": "^4.1.4", "stylelint": "^16.10.0", "stylelint-config-recess-order": "^5.1.1", @@ -3223,6 +3224,19 @@ } } }, + "node_modules/eslint-config-prettier": { + "version": "9.1.0", + "resolved": "https://registry.npmjs.org/eslint-config-prettier/-/eslint-config-prettier-9.1.0.tgz", + "integrity": "sha512-NSWl5BFQWEPi1j4TjVNItzYV7dZXZ+wP6I6ZhrBGpChQhZRUaElihE9uRRkcbRnNb76UMKDF3r+WTmNcGPKsqw==", + "dev": true, + "license": "MIT", + "bin": { + "eslint-config-prettier": "bin/cli.js" + }, + "peerDependencies": { + "eslint": ">=7.0.0" + } + }, "node_modules/eslint-import-resolver-node": { "version": "0.3.9", "resolved": "https://registry.npmjs.org/eslint-import-resolver-node/-/eslint-import-resolver-node-0.3.9.tgz", diff --git a/package.json b/package.json index 2369605..9a9a50a 100644 --- a/package.json +++ b/package.json @@ -21,6 +21,7 @@ "@types/react-dom": "^18", "eslint": "^8.57.1", "eslint-config-next": "15.0.2", + "eslint-config-prettier": "^9.1.0", "eslint-plugin-unused-imports": "^4.1.4", "stylelint": "^16.10.0", "stylelint-config-recess-order": "^5.1.1", diff --git a/src/app/firebase.ts b/src/app/firebase.ts new file mode 100644 index 0000000..25e5bf7 --- /dev/null +++ b/src/app/firebase.ts @@ -0,0 +1,21 @@ +// Import the functions you need from the SDKs you need +import { getAnalytics } from "firebase/analytics"; +import { initializeApp } from "firebase/app"; +// TODO: Add SDKs for Firebase products that you want to use +// https://firebase.google.com/docs/web/setup#available-libraries + +// Your web app's Firebase configuration +// For Firebase JS SDK v7.20.0 and later, measurementId is optional +const firebaseConfig = { + apiKey: "AIzaSyBLxm_wzrLxPrSypwC9ph8ftGEwF99yVLM", + authDomain: "todo-real-c28fa.firebaseapp.com", + projectId: "todo-real-c28fa", + storageBucket: "todo-real-c28fa.firebasestorage.app", + messagingSenderId: "525849418012", + appId: "1:525849418012:web:9abf3c10d5553f39a902d9", + measurementId: "G-ZLSZV42KFZ", +}; + +// Initialize Firebase +const app = initializeApp(firebaseConfig); +const analytics = getAnalytics(app); diff --git a/src/app/page.module.scss b/src/app/page.module.scss index 30dd2e1..1ea5adb 100644 --- a/src/app/page.module.scss +++ b/src/app/page.module.scss @@ -154,9 +154,3 @@ a.secondary { justify-content: center; } } - -@media (prefers-color-scheme: dark) { - .logo { - filter: invert(); - } -}