Create a Controller and Service

Follow step-by-step instructions to create a controller and service using NestJS CLI.

Controller and service

In this lesson, we’ll build AddressController and its corresponding service. Controllers and services are the heart of our application. They’re responsible for handling incoming requests, processing data, and orchestrating address information flow. By building AddressController and its service, we’re laying the foundation for our API and bringing us one step closer to the complete CRUD functionalities.

Create AddressController

As we learned in the previous lesson, a controller receives incoming requests, passes the requests to a service, and then returns the service result to the client.

The following command generates AddressController:

Get hands-on with 1400+ tech skills courses.