/nestjs-mvc

Primary LanguageTypeScript

Just a simple learning project

Setup:

To Do:

  • User can sign up with basic validation
  • Password should not be returned post creating user (use a DTO to dictate the return value)
  • Should display friendly message if duplicate email used when creating user or when validation fails for non-conforming data
  • User can login
  • User automatically logged in after creation
  • User can logout
  • Redirect if visiting authenticated routes
  • Render if failed to create user
  • Render if login failed
  • Use Interceptor to add flashMessages and csrfToken to every response
  • Testing

Uncertainties:

  • Haven't decided where is the best place to implement mappers a.k.a. toUserDto
  • Any way to make toUserDto more generic and reusable

New Lessons for me:

  1. Use guards to perform login
  2. Use guards to perform authorization
  3. Use exception filters to improve user experience by redirecting when fail to login or when visting unauthorized routes
  4. Use exception filters to improve UX when user sign up fails by rendering the sign up form page with error messages
  5. Use flash messages
  6. Use CSRF
  7. Use passport.js together with express-session for a "username" / password local strategy
  8. Use global interceptors in app module to inject csrftoken and flash message to every route handler