Reader small image

You're reading from  Nest.js: A Progressive Node.js Framework

Product typeBook
Published inNov 2019
Reading LevelIntermediate
PublisherPackt
ISBN-139781800204737
Edition1st Edition
Languages
Tools
Right arrow
Authors (5):
Greg Magolan
Greg Magolan
author image
Greg Magolan

Greg Magolan is a senior architect, full-stack engineer, and Angular consultant at Rangle. He has been developing enterprise software solutions for over 15 years for companies such as Agilent Technologies, Electronic Arts, Avigilon, Energy Transfer Partners, FunnelEnvy, Yodel and ACM Facility Safety.
Read more about Greg Magolan

Patrick Housley
Patrick Housley
author image
Patrick Housley

Patrick Housley is a lead technologist at VML. He is an IT professional with over six years of experience in the technology industry. He is capable of analyzing complex issues spanning multiple technologies while providing detailed resolutions and explanations. He has strong front-end development skills with experience leading development teams in maintenance and greenfield projects.
Read more about Patrick Housley

Adrien de Peretti
Adrien de Peretti
author image
Adrien de Peretti

Adrien de Peretti is a full-stack JavaScript developer. He is passionate about new technologies and is constantly looking for new challenges. He is especially interested in artificial intelligence and robotics. W
Read more about Adrien de Peretti

Jay Bell
Jay Bell
author image
Jay Bell

Jay Bell is the CTO of Trellis. He is a senior Angular developer who uses Nest.js in production to develop industry-leading software to help non-profit organizations and charities in Canada. He is a serial entrepreneur who has developed software for a large range of purposes, from helping combat wildfires with drones to building mobile apps.
Read more about Jay Bell

David Guijarro
David Guijarro
author image
David Guijarro

David Guijarro is a front-end developer at Car2go Group GmbH. He has a wide experience working within the JavaScript ecosystem. He has successfully built and led multicultural, multifunctional teams.
Read more about David Guijarro

View More author details
Right arrow

Sending data

The previous microservice handler was very contrived. It is more likely that microservice handlers will be implemented to perform some processing on data and return some value. In a normal HTTP handler, we would use @Req or @Body to extract the data from the HTTP request’s body. Since microservice handlers have no HTTP context, they take input data as a method parameter.

@Controller()
export class UserController {
    @Client({transport: Transport.TCP, options: { port: 5667 }})
    client: ClientProxy

    @Post('users')
    public async create(@Req() req, @Res() res) {
        this.client.send({cmd: 'users.index'}, {}).subscribe({
            next: users => {
                res.status(HttpStatus.OK).json(users);
            },
            error: error => {
                res.status(HttpStatus.INTERNAL_SERVER_ERROR).json(error);
            }
        });
    }

    @MessagePattern({cmd: 'users.create'})
    public async rpcCreate...
lock icon
The rest of the page is locked
Previous PageNext Page
You have been reading a chapter from
Nest.js: A Progressive Node.js Framework
Published in: Nov 2019Publisher: PacktISBN-13: 9781800204737

Authors (5)

author image
Greg Magolan

Greg Magolan is a senior architect, full-stack engineer, and Angular consultant at Rangle. He has been developing enterprise software solutions for over 15 years for companies such as Agilent Technologies, Electronic Arts, Avigilon, Energy Transfer Partners, FunnelEnvy, Yodel and ACM Facility Safety.
Read more about Greg Magolan

author image
Patrick Housley

Patrick Housley is a lead technologist at VML. He is an IT professional with over six years of experience in the technology industry. He is capable of analyzing complex issues spanning multiple technologies while providing detailed resolutions and explanations. He has strong front-end development skills with experience leading development teams in maintenance and greenfield projects.
Read more about Patrick Housley

author image
Adrien de Peretti

Adrien de Peretti is a full-stack JavaScript developer. He is passionate about new technologies and is constantly looking for new challenges. He is especially interested in artificial intelligence and robotics. W
Read more about Adrien de Peretti

author image
Jay Bell

Jay Bell is the CTO of Trellis. He is a senior Angular developer who uses Nest.js in production to develop industry-leading software to help non-profit organizations and charities in Canada. He is a serial entrepreneur who has developed software for a large range of purposes, from helping combat wildfires with drones to building mobile apps.
Read more about Jay Bell

author image
David Guijarro

David Guijarro is a front-end developer at Car2go Group GmbH. He has a wide experience working within the JavaScript ecosystem. He has successfully built and led multicultural, multifunctional teams.
Read more about David Guijarro