Files
main.tsmain
What you'll learn
- Create a parameter decorator with createParamDecorator and use its data argument to select a property
- Compose several decorators into one named decorator with applyDecorators
- Place every stage of the request pipeline in order: middleware, guards, interceptors, pipes, handler, interceptors, filters
Press Run tests to start the app. Its log appears here.Graded endpoints
@User('name') hands the handler the current user's name, stored as createdBy
A second cat, owned by ada
Only bob's cat
No user on the request: the decorator yields undefined, nothing matches, and nothing crashes
A handler without @Auth is open to anyone
@Auth('admin') requires a role and there is no user: the guard from lesson 8 answers 401
@Auth('admin') bundles the role metadata and the guard: a reader is refused
An admin may delete
Only Kitty is left