NestJS: Introduction
Tags: node, javascript, typescript, backend
Published: 2020-06-14 19:02:23

This is the first post about NestJS. The introduction

NestJS is a framework for building efficient, scalable Node.js server-side applications. It uses progressive JavaScript, is built with and fully supports TypeScript (yet still enables developers to code in pure JavaScript) and combines elements of Object Oriented Programming, Functional Programming, and Functional Reactive Programming.

Under the hood, Nest makes use of robust HTTP Server frameworks like Express (the default) and optionally can be configured to use Fastify as well!

Nest provides a level of abstraction above these common Node.js frameworks (Express/Fastify), but also exposes their APIs directly to the developer. This allows developers the freedom to use the myriad of third-party modules which are available for the underlying platform.

#**Prerequisites**
You have to make sure that Node.js (>= 10.13.0) is installed on your operating system.

##**Language**
NestJS is built with and fully supports TypeScript. However, Nest is compatible with both TypeScript and pure JavaScript. This framework takes advantage of the latest language features, so to use it with vanilla JavaScript we need a Babel compiler.

#**Why NestJS?**
The main problem with other javascript frameworks is the structure of the project made with them. The majority of them has many powerful features and solutions but they dont have a easy testeable structure or a heavily convoluted file tree. However, Nest provides an out-of-the-box application architecture which allows developers and teams to create highly testable, scalable, loosely coupled, and easily maintainable applications. The architecture is heavily inspired by [Angular](https://angular.io).

#**Strengths**

[X] Typescript and Javascript fully support
[X] Powerful CLI
[X] Decorators
[X] Extensible, Versatile, Progressive
[X] Open Source
[X] GraphQL Friendly
[X] WebSockets integrated

#**Powerful CLI**
The Nest CLI is a command-line interface tool that helps you to initialize, develop, and maintain your Nest applications. It assists in multiple ways, including scaffolding the project, serving it in development mode, and building and bundling the application for production distribution. It embodies best-practice architectural patterns to encourage well-structured apps.

All nest commands follow the same format:

```
nest commandOrAlias requiredArg [optionalArg] [options]
```
Command overview
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/u05in101xrjhue2wa5li.PNG)

#**Platform**
Nest aims to be a platform-agnostic framework. Platform independence makes it possible to create reusable logical parts that developers can take advantage of across several different types of applications. Technically, Nest is able to work with any Node HTTP framework once an adapter is created. There are two HTTP platforms supported out-of-the-box: express and fastify. You can choose the one that best suits your needs.

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/azuu8dxgjtje1q2qh8yv.PNG)

##**Installation**
{% github nestjs/nest %}

Install via npm: 

```
npm i -g @nestjs/cli
nest new project-name
```

Install via yarn: 
```
yarn add @nestjs/cli
nest new project-name
```

##**Useful Templates**

Made with [Docker](https://www.docker.com) and [Prisma](prisma.io): 

{% github z1-lab/nestjs-backend-template %}

Typescript nestjs starter: 

{% github nestjs/typescript-starter %}

- - -

_Follow me on [Twitter](https://twitter.com/torresc_alvaro) if you want to know about my future articles, projects or whatever_