I am at class 27 and today’s modules have been:
- Custom queries and hooks (checking and saving unique
slug
s, compound mongoose aggregations,Promise.all
) - 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 aschema.pre('save')
function as it is not yet instantiated - adding custom
statics
method in a schema withthis.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
, andnormalizeEmail
’ - how to use
es6-promisify
to make User.register (frompassport-local-mongoose
) promised - how to properly setup an
authController
Strategy for passport at theapp.js
level - userschema virtual field and GRAVATAR GRABBING
crypto
module in node!!!