Files
main.tsmain
What you'll learn
- Make an HTTP application listen on a transport too, with connectMicroservice() and startAllMicroservices(), and know the order they must run in
- Handle messages or events in the same controllers that serve routes
- Know that global pipes, guards, interceptors and filters apply to a connected microservice only with inheritAppConfig
- Let a service publish events to the apps that care, with a client pointing back at them
Press Run tests to start the app. Its log appears here.Graded endpoints
The adoption is a message now: the service records it and replies with the cat
The service published 'cat.adopted' to the gateway's own TCP port, and the gateway's global pipe, shared through inheritAppConfig, turned the date back into a Date
A message has a reply, so the gateway learns what an event could not tell it: Tom is already home
An unknown cat is the service's 404
The same global ValidationPipe guards the HTTP door: the body is refused before anything is sent
A second adoption, a second event
Only the adoptions that happened are in the feed: the refused ones published nothing
The lookup from the first lesson still asks the service by message
Luna was never adopted: the invalid request never reached the service