Files
main.tsmain
What you'll learn
- Write a provider with @Injectable() and receive it through a constructor
- Keep state in a service and see one instance shared across requests
- Throw NotFoundException and get Nest's 404 body without writing response code
Press Run tests to start the app. Its log appears here.Graded endpoints
The service stores the cat and returns it with its id
The same service instance answers, so the second cat gets the next id
Both cats, in the order they were created: the array lives as long as the app
findOne() looks the cat up by id
A cat that does not exist is a 404 from NotFoundException, with Nest's body for it
remove() returns the cat it took out
Tom is gone, so removing him again is the same 404 as looking him up
Only Luna is left