Skip to content
Open
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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ node_modules/
.env.local
.env.*.local
gopredict-env/
frontend\.env.local

# Python
__pycache__/
Expand Down
25 changes: 25 additions & 0 deletions backend/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@


.env

# Node modules
node_modules/

# TypeScript compiled output
dist/

# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
pnpm-debug.log*
lerna-debug.log*

# OS generated files
.DS_Store
Thumbs.db


config/serviceAccountKey.json
34 changes: 34 additions & 0 deletions backend/config/firebaseAdmin.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import * as admin from 'firebase-admin';
import dotenv from 'dotenv';
import path from 'path'; // Import path module

dotenv.config(); // Load environment variables

const serviceAccountPath = process.env.FIREBASE_SERVICE_ACCOUNT_KEY_PATH;

if (!serviceAccountPath) {
console.error(' FATAL ERROR: FIREBASE_SERVICE_ACCOUNT_KEY_PATH is not defined in .env file');
process.exit(1);
}

// Construct the absolute path from the project's root directory (where package.json is)
const absolutePath = path.resolve(process.cwd(), serviceAccountPath);

try {
// eslint-disable-next-line @typescript-eslint/no-var-requires
const serviceAccount = require(absolutePath); // Use the absolute path

admin.initializeApp({
credential: admin.credential.cert(serviceAccount)
});

console.log(' Firebase Admin SDK Initialized Successfully');

} catch (error: any) {
console.error('Firebase Admin SDK Initialization Error:', error.message);
console.error(`Attempted to load key from: ${absolutePath}`);
console.error('Ensure the path in .env is correct (relative to project root) and the JSON file exists.');
process.exit(1);
}

export default admin;
32 changes: 32 additions & 0 deletions backend/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
{
"name": "backend",
"version": "1.0.0",
"description": "",
"main": "dist/server.js",
"scripts": {
"dev": "ts-node-dev --respawn --transpile-only src/server.ts",
"build": "tsc",
"start": "node dist/server.js",
"test": "echo \"Error: no test specified\" && exit 1"
},
"keywords": [],
"author": "",
"license": "ISC",
"packageManager": "pnpm@10.19.0",
"dependencies": {
"@types/mongoose": "^5.11.97",
"cors": "^2.8.5",
"dotenv": "^17.2.3",
"express": "^5.1.0",
"firebase-admin": "^13.5.0",
"mongodb": "^6.20.0",
"mongoose": "^8.19.2"
},
"devDependencies": {
"@types/cors": "^2.8.19",
"@types/express": "^5.0.4",
"@types/node": "^24.9.1",
"ts-node-dev": "^2.0.0",
"typescript": "^5.9.3"
}
}
Loading
Loading