Files
main.tsmain
What you'll learn
- Answer one message with several events by returning an Observable of { event, data }
- Return a promise from a handler and know the acknowledgement waits for it
- Acknowledge by hand with @Ack(), and know Nest then ignores the return value
- Inject a gateway into a controller or service and use its server to tell every socket about a change made over HTTP
Press Run tests to start the app. Its log appears here.Graded endpoints
The first client
A second client, to hear what the HTTP API announces
An Observable of { event, data } sends one event per value until it completes; nothing is acknowledged, and only Ada asked
The handler returns a promise; the acknowledgement is sent when it resolves, 100 ms later
An unknown cat is still acknowledged, with an error object
@Ack() acknowledges the import before the work; each stored cat then follows as its own event, to Ada only
The controller creates the cat and the gateway's server announces it: every socket hears cats:added
Imported over the socket or posted over HTTP, it is one CatsService
The stream follows the cats as they are now: five items and the count
run the tests first
Frames
Run the tests first.