This repository contains the backend code for our application, built with Express.js and integrated with Firebase.
src/
routes/
: API route definitionscontroller/
: Request handlers for routesmiddleware/
: Custom middleware functionsconfig/
: Configuration files, including Firebase setupentities/
: Shared entity definitions (e.g., ApiError)repository/
: Data access layer for Firestore
- Clone the repository
- Install dependencies:
npm install
- Set up Firebase configuration in
src/config/firebase.ts
- Install Firebase CLI:
npm install -g firebase-tools
- Login to Firebase:
firebase login
- Start the server:
npm start
POST /update-user-data
: Updates user data in FirestoreGET /fetch-user-data
: Fetches user data from Firestore
Both endpoints require authentication via the authMiddleware
.
The application uses a custom ApiError
class for standardized error responses.
Requests are authenticated using Firebase Authentication. The authMiddleware
validates the request token before allowing access to protected routes.
To run the server in development mode with hot reloading: npm run dev
To run the Firebase Emulator Suite:
- Build the project:
npm run build
- Start the emulator:
npm run dev:emulator
This will start the Firebase Emulator for Firestore on port 8080.
Create a .env
file in the root directory with the following variables:
- FIREBASE_PROJECT_ID
- FIREBASE_CLIENT_EMAIL
- FIREBASE_PRIVATE_KEY
For local development using the Firebase Emulator, set:
- FIRESTORE_EMULATOR_HOST=localhost:8080
Firestore security rules are defined in firestore.rules
. Make sure to review and update these rules as needed to secure your data.
Please read CONTRIBUTING.md for details on our code of conduct and the process for submitting pull requests.
This project is licensed under the MIT License - see the LICENSE.md file for details.