An Opinionated, Maintainable REST API Architecture for ASP.NET Core

An Opinionated, Maintainable REST API Architecture for ASP.NET Core

NDC Conferences via YouTube Direct link

SETTING THE STAGE "We need a new SPA "We need a new REST API

2 of 23

2 of 23

SETTING THE STAGE "We need a new SPA "We need a new REST API

Class Central Classrooms beta

YouTube playlists curated by Class Central.

Classroom Contents

An Opinionated, Maintainable REST API Architecture for ASP.NET Core

Automatically move to the next video in the Classroom when playback concludes

  1. 1 Intro
  2. 2 SETTING THE STAGE "We need a new SPA "We need a new REST API
  3. 3 ZERO TO "MAKE MAGIC HAPPEN"
  4. 4 THE EMPLOYEE OBJECT • Is part of payroll software • Contains sensitive data (SSN)
  5. 5 A WILD EmployeesController APPEARED
  6. 6 The reality SCAFFOLDING IS A LIE
  7. 7 Route the request Validate Run service for request Return data
  8. 8 NO SEPARATION OF CONCERNS
  9. 9 CONTROLLER SHOULD ONLY Route the request Return data
  10. 10 CQRS Command Query Responsibility Segregation
  11. 11 Problem? ENTITY BEING USED FOR REQUESTS MODEL/MODEL VALIDATION ARE NOT SEPARATE
  12. 12 SEPARATE ENTITY FROM MODEL So let's refactor
  13. 13 SEPARATE VALIDATION FROM MODEL INTRODUCING FLUENT VALIDATION
  14. 14 ISOLATE VALIDATION FUNCTIONALITY
  15. 15 SEPARATE REQUEST HANDLER FROM CONTROLLER INTRODUCING MEDIATR
  16. 16 PUTTING IT ALL TOGETHER 1. Dependency injection handles... dependencies 2. Mediat will handle request/responses 3. Controller will route HTTP requests
  17. 17 USE BETTER DI CONTAINER INTRODUCING AUTOFAC
  18. 18 USE AUTOFAC TO • Scan assemblies for services/validators • Add them to service pipeline
  19. 19 TIPS
  20. 20 CREATE REPEATABLE PATTERNS more complete example
  21. 21 WRITE TESTS FOR EVERYTHING
  22. 22 KEEP VERSIONS SEPARATE
  23. 23 CONCERNS May be unnecessary complexity • Bigger learning curve

Never Stop Learning.

Get personalized course recommendations, track subjects and courses with reminders, and more.

Someone learning on their laptop while sitting on the floor.