This project is a backend for Task Assist built with Firebase Cloud Functions and Express in TypeScript. It uses MongoDB as the data store and is designed to run seamlessly both locally (via the Firebase Emulator) and on Firebase.
/Task-Assist-Backend βββ .env # Environment variables (root) βββ .firebaserc # Firebase project configuration βββ firebase.json # Firebase configuration βββ README.md # This documentation βββ jest.config.js # Jest configuration for tests (optional) βββ package.json # Root-level package.json (optional) βββ functions # Firebase Functions folder βββ .gitignore # Ignores node_modules, lib folder, etc. βββ package.json # Functions dependencies & scripts βββ tsconfig.json # TypeScript configuration βββ src βββ index.ts # Entry point β wraps Express app as a Cloud Function βββ app.ts # Express app configuration (middlewares, routes) βββ config β βββ db.ts # MongoDB connection helper βββ models β βββ taskModel.ts # Task model interface βββ routes βββ taskRouter.ts # Express routes for tasks
## βοΈ Prerequisites
- **Node.js v22**
(as specified in `functions/package.json` β `engines`)
- **Firebase CLI**
Install globally with:
```bash
npm install -g firebase-toolsA Firebase project (Ensure the project ID is configured in .firebaserc)
π οΈ Setup Instructions
1.Clone the Repository
git clone https://github.com/brandon-ide/Task-Assist-Backend.git
cd Task-Assist-Backend2.Install Root Dependencies (if applicable) (Only if you have shared dependencies or scripts in the root)
npm install3.Setup Firebase Functions Navigate into the functions folder and install its dependencies:
cd functions
npm install4.Configure Environment Variables
Create or update the bash.env file in the root directory with your MongoDB URI and any other secrets:
URI=mongodb+srv://<username>:<password>@cluster.mongodb.net/TaskAssist?retryWrites=true&w=majority5.Build the Functions
From the bash functions folder, compile the TypeScript files:
npm run build6.Run Locally with Firebase Emulators First, set your Firebase project (if you havenβt already):
firebase use --addThen, start the emulator:
npm run serveThe emulator loads your Cloud Function (wrapped Express app) for local testing.
7.Deploy to Firebase When ready, deploy your functions with:
npm run deployπ Testing If tests are set up, run:
npm testπ‘ Notes Node Version: Ensure you are using Node.js v22. If not, use nvm to manage Node versions. Firebase Project Configuration: If the emulator complains about a missing project ID, run:
firebase use --addRebuilding: For every change in your TypeScript files, rebuild with:
npm run build
Ballers Team