I am at class 27 and today’s modules have been:

  1. Custom queries and hooks (checking and saving unique slugs, compound mongoose aggregations, Promise.all)
  2. User accounts and auth (defining a user/pw schema with passport.js, auth protecting routes, account updating, forgot password)

nonobvious things to note:

  • using this.constructor.find() in a schema.pre('save') function as it is not yet instantiated
  • adding custom statics method in a schema with this.aggregate([{$unwind:'$tags'},{group, sort etc...}])
  • supplying the edge case of no query in a search with {$exists: true}
  • how to make middleware to validate registration with validator.sanitizeBody, checkBody, and normalizeEmail
  • how to use es6-promisify to make User.register (from passport-local-mongoose) promised
  • how to properly setup an authController Strategy for passport at the app.js level
  • userschema virtual field and GRAVATAR GRABBING
  • crypto module in node!!!