Building a basic REST API
As we embark on this exciting phase of building a REST API, let’s refresh our memory of the core concepts we’ve learned so far. Remember the environment setup from Chapter 3 and the deep dive into modules, controllers, providers, exception filters, pipes, guards, and decorators in Chapter 4? We’re about to bring all these elements into play.
Setting up your REST API project
Whether you’re continuing with the NestJS application from Chapter 2 or starting afresh, the principles remain the same. Let’s begin by setting up our project environment:
- For a new project, run
nest new project-name
in your terminal. - For an existing project, navigate to your existing project directory.
- Understanding the structure: Observe the default folders – that is,
controllers
,modules
, and so on – just as we did in Chapter 2, as a way for you to refresh your memory:- Running the application: Start the application...