This project has two binaries actually:
- a TCP-based microservice using Nestjs; and
- a corresponding TCP client which invokes a remote procedure and prints the output.
tl;dr
$ npm install
# start the server on 0.0.0.0:1888
$ npm run start:dev
# in another shell, run the client
$ npx ts-node src/client
The client will send both request-response and event-based messages:
- a request
CmdHello
which expects anObservable<string>
in return; and - an event
EvtAhoy
which is broadcast to the server in its own namespace.
$ npx ts-node src/client
[Nest] 812632 - 04/26/2021, 8:53:45 AM [NestFactory] Starting Nest application...
[Nest] 812632 - 04/26/2021, 8:53:45 AM [InstanceLoader] ClientsModule dependencies initialized +23ms
[Nest] 812632 - 04/26/2021, 8:53:45 AM [InstanceLoader] ClientModule dependencies initialized +0ms
sending request for hello
emitting event: ahoy
got value: Hello from the server!
Shutting down ...
Meanwhile, the server should look something like:
$ npm run start:dev
[Nest] 812606 - 04/26/2021, 8:53:41 AM [NestFactory] Starting Nest application...
[Nest] 812606 - 04/26/2021, 8:53:41 AM [InstanceLoader] ServerModule dependencies initialized +25ms
[Nest] 812606 - 04/26/2021, 8:53:41 AM [NestMicroservice] Nest microservice successfully started +3ms
Microservice is listening
data:
"ahoy" broadcast from the client
The rest of this document is the auto-generated Nestjs documentation!
A progressive Node.js framework for building efficient and scalable server-side applications.
Nest framework TypeScript starter repository.
$ npm install
# development
$ npm run start
# watch mode
$ npm run start:dev
# production mode
$ npm run start:prod
# unit tests
$ npm run test
# e2e tests
$ npm run test:e2e
# test coverage
$ npm run test:cov
Nest is an MIT-licensed open source project. It can grow thanks to the sponsors and support by the amazing backers. If you'd like to join them, please read more here.
- Author - Kamil Myśliwiec
- Website - https://nestjs.com
- Twitter - @nestframework
Nest is MIT licensed.