This repo contains the code for the backend nodejs server for any frontend apps. It's a simple node app built using express for setup and routing, and firebase for authorizing, reading, and writing data.
npm start or npm run start
Either command will launch a local server, by default on port 9000 (this can be changed in the .env file). Simply go to localhost:9000 to see the app.
npm run dev
This will do the same as above, but the server will auto-restart when any new changes to files are made. Simply refresh the browser to see the latest changes.
package.json - defines dependencies and npm commands for running the app (like requirements.txt in python)
package-lock.json - a more detailed version of the above, designed to be put under version control
server.js - core setup of the app (registering routes, port, database, etc)
routes.js - location of the all the API endpoints
controllers/ - folder for different controller for managing database access
models/ - folder for various collection schemas in firebase
.env - config file for storing sensitive data (e.g. db credentials) or global config options (e.g. server port); this file is not under version control for security reasons
dotenvdontenv allows us to load app configuration files from a.envfile in the root of the app directoryexpressexpress is the core framework for server and route creation (like Flask or Sanic)firebasefirebase is for database read/write operationsfirebase-adminfirebase-admin is for database configuration and user authorizationmorgansimple server-side logging for requests and stuffbabelandbabel-preset-envthese packages are for "transpiling", i.e. allowing us to write javascript using the most modern syntax (e.g.import) while allowing compatibility with various node versions that may not support the new syntax
corscors for cross-origin requestsbody-parserbody-parser for parsing incoming request bodies