This repository contains the Firestore rules, Firestore indexes, and Firebase cloud functions used in CruzHacks 2024 sites. The mentality for this years hackathon sites was to eliminiate the need for a full api layer by instead using firebase's Javascript library to retrieve assets.
The existing backend functions use Express with custom middleware to validate Firebase authenticated Id tokens. Additionally, to secure the backend Firestore rules were used in combination with Firebase Custom Claims to specify user roles (e.g. "hacker", "admin", etc.).
Therefore, the code here mostly contains triggers to maintain Custom Claim roles, as well as special operations that are too combersome or complex for purely frontend code.
- Clone this repository
- Install nvm to manage versions of node
- Run
nvm install 18
andnvm use 18
to use version 18 of node - Install firebase-tools to emulate backend and run deploys
- Navigate to the functions directory and run
yarn
to install all the dependencies - Find/create .env file according to .env.sample
- Run
yarn build
to transpile the typescript into the lib folder - Use
firebase login
to gain access to firebase, andfirebase use default
to set the correct project alias - Run
yarn start
to start typescript compilation and the firebase emulators!
yarn lint
-> lints codeyarn build
-> transpiles typescript into lib folderyarn start
-> transpiles typescript and runs firebase emulatorsyarn shell
-> transpiles typescript and runs interactive shell to test functionsyarn deploy
-> deploys firebase functions to firebaseyarn logs
-> print log to stdout