Yelpcamp Docs

Order of app creation

Phase One

  1. Setup basic Express and EJS app
  2. Setup basic Mongoose Models and connect to a MongoDb db
    • Create some dummy data in the code to run and check the db in the Mongo shell
  3. Seed DB with data connecting to Mongo DB, Mongoose and models seperately from the rest of the app.
    • We run this file everytime we make changes to our models or data to seed the db for testing purposes.
  4. Add basic CRUD operations

Phase Two

  1. Add basic design/styles (Mainly partials such as navs and footers to avoid duplicating code)
    • Use EJS Mate for boilerplate templating

Phase Three

  1. Handle errors and validating data
    1. Client side form validations
    2. Basic error handling
      1. catchAsync wrapper function
      2. Defining ExpressError class
    3. Defining error templates
    4. Server side validations with Joi middleware
      1. Joi helps us validate data on server side and throw specific errors easily.

Phase Four

  1. Adding a reviews model for the reviews feature for campgrounds

Phase Five

  1. Restructuring Express routes
  2. Serve static assets (creating a public folder for all JS scripts, CSS files, images and other static assets.)
  3. Adding sessions
  4. Adding flash messages

Phase Six

  1. Adding authentication
    1. Create a user model
    2. Configue passport
    3. Set up the register form and route
    4. Set up the login form and route
    5. Keep a user logged in with isLoggedIn middleware
    6. Adding logout functionality

Phase Seven

  1. Configuring Authorization (what users should have / not have access to)

Phase Eight

  1. Build the rest of the apps features

Phase Nine

  1. Clean up styles/app
  2. Fix common security issues
    1. Mongo/SQL injection
    2. Cross site scripting (XSS)
    3. Changes to cookies
    4. Hiding error stack trace in production
    5. Using helmet npm package

Phase Ten

  1. Deploying
    1. Deploy DB to servers using Mongo Atlas
      1. Build first cluster
      2. Create db user
      3. Add my IP address to list of approved IPs
      4. Connect to DB through application
        1. copy db URL
        2. Paste URL in .env file and paste the user password into URL where is says password
        3. In app.js write a const dbUrl = process.env.DB_URL
        4. Replace URL in Mongoose.connect to dbUrl
      5. Configure to store session information in Mongo
        1. Install connect mongo npm package
        2. Require package
        3. Configure store in sessionConfig
      6. Deploy app
        1. Change dbs to be live db OR local
        2. Change db secret to be .env secret OR dev secret
        3. Create .gitignore file and include node_modules and .env

List of sources

    Colt Steeles web developer bootcamp 2021