Firebase backend for chipstackoverflow
We're using Firebase Emulators for local development. Hit npm run dev to run emulators after installing dependencies with npm install.
# install dependencies
npm install
# run firebase emulators
npm run dev
We're using 5 Firebase products:
- Authentication
- Cloud Firestore
- Cloud Functions
- Cloud Storage
- Hosting
All users' API call is towards GraphQL cloud function, instead of directly fetching data from Firestore in order to make API playground and clear auto-generated documentation. Therefore, security rules of Firestore denies all.
- We're using Firestore as a datastore that allows alomost infinite number of connections. So that we can use cloud functions as a Web API.
- Authenticaion is resolved by JSON Web Token, therefore we don't have extra datastore fetch to verify authentication token.
- We're using Apollo GraphQL server implementation and resolver chains hard to fetch child-layer data by users' demand.
- Models are well typed by TypeScript. We check pessimisticly data types to write to datastores but cast optimisticly data to be typed from datastores. Type checking are working on TypeScript's Branded Types, which can be added in TypeScript as "Nominal Types" (discussion), and Assertion Functions.
- We're using dataloader to prevent N+1 fetch to datastores.
No license
