Very First App and Project Structure
First Steps
Hello and welcome to NestJS!
In this course, we'll get familiar with the essentials of NestJS by building a basic CRUD application. In this particular unit, we'll acquaint ourselves with the basic structure of a NestJS application and the CodeSignal environment.
Technologies Used
Before we dive into the code, let’s take a moment to understand the technologies we’ll be using in this unit:
- TypeScript: NestJS is built on top of TypeScript, a typed superset of JavaScript that provides static typing and other advanced features for writing maintainable code.
- NestJS: A framework for building scalable server-side applications, heavily inspired by Angular.
- Express: NestJS uses Express as the default HTTP server, though it can be swapped out for others like Fastify.
- Handlebars (hbs): A simple templating engine that allows you to dynamically render HTML pages.
This course assumes you already have a basic understanding of TypeScript and some familiarity with HTTP concepts. If you're comfortable with these technologies, you'll be well-prepared to follow along with the lessons.
Setup and Installation
To start working with NestJS, you need to install the Nest CLI globally on your machine. The CLI helps scaffold a new project and provides several useful commands for development:
These commands will install the Nest CLI and create a new project with the name you provide. However, in the practice section, you’ll find that we’ve already set up a NestJS environment for you, so you can focus on understanding the project structure and writing some code.
Project Files and Directory Structure
When you create a new NestJS project, several files and directories are generated. Let’s take a look at the five key files created and their roles:
- src/
- app.controller.spec.ts: A test file for the
AppController. It uses Jest for testing the controller’s functionality. - app.controller.ts: This file defines the
AppController, responsible for handling incoming requests and returning responses. - app.module.ts: The root module of your application, which organizes controllers, providers (like services), and other modules.
- app.service.ts: This file defines the
AppService, which contains the business logic used by theAppController. - main.ts: The entry point of the application where the NestJS app is bootstrapped and configured.
- app.controller.spec.ts: A test file for the
Throughout the upcoming units, we’ll dive deeper into what each of these files does, but for now, let's focus on the main.ts file where the program bootstraps (or starts).
