Controllers
Controllers in Nest are responsible for handling incoming requests and returning responses to the client. Nest will route incoming requests to handler functions in controller classes. We use the @Controller()
decorator to create a controller class.
import
{
Controller
,
Get
}
from
'@nestjs/common'
;
@
Controller
(
'entries'
)
export
class
EntryController
{
@
Get
()
index
()
:
Entry
[]
{
const
entries
:Entry
[]
=
this
.
entriesService
.
findAll
();
return
entries
;
}
We’ll go over the details of routing and handling requests in the Routing and Request Handling chapter.