Files
main.tsmain
What you'll learn
- Provide a class Nest cannot construct through useFactory, with other providers handed in through inject
- Alias one instance under a second token with useExisting, and know why useClass there would be a second instance
- Choose an implementation at startup with a useClass expression, and mark an injected token optional
Press Run tests to start the app. Its log appears here.Graded endpoints
The repository exists, built by the factory, so the service boots and stores a cat
Second cat
The service lists through the same repository
The alias resolves to the same repository the service writes to, and the capacity came from the config through inject
Third of three
The factory gave the repository its capacity from the config, so the fourth is refused
Still one repository: the alias counts three