Module 07 Activity
Scenario
Move shared request-time concerns into dependencies without pulling logic in with them.
What you build
Dependencies for settings, clients, authentication and sessions - overridable in tests, with business logic left in services.
Steps
- Convert repeated checks at the top of handlers into dependencies, and confirm they appear in the generated documentation.
- Put expensive objects behind a cached dependency and prove they are built once across several requests.
- Use route-level dependencies for checks that guard rather than supply.
- Override one dependency in a test and confirm the whole request path still runs.
- Audit your dependencies for business logic and move any you find into services.
- Check no dependency chain is more than two or three deep.
Evidence to hand in
- The converted dependencies, visible in the docs.
- The build count for the cached dependency.
- A route-level guard.
- The override with evidence the path still ran.
- The business-logic audit.
Review checklist
- Converted dependencies appear in the generated documentation.
- The expensive dependency is built once across several requests.
- Guards use route-level dependencies rather than unused parameters.
- The override is cleared after the test.
- No dependency contains business logic.
