Spring 개발 유경험자로 Node를 처음 접하며 Study하는 내용을 기록해보고자 한다. 

 

1. NestJS는?

 

NestJS는 Node.js 기반의 웹 API 프레임워크이다. 들어만 본 Express를 사용하고, Node.js의 자체 특성인 사용하기 쉽고, 확장성이 뛰어나다. 이로 인해 품질이 일정치 않고, 적합한 라이브러리를 찾기 위해 사용자의 수고가 필요하다는 단점이 있는데 이를 보완하는 것이 NestJS이다.

 

Angular의 영향을 많이 받은 NestJS는 DI(Dependency Injection, 의존성 주입)이라는 객체지향 개념을 도입한 부분에서 Spring과 공통점이 있다. 소스를 보아도 스프링에서 Anotation이라고 불리는 '@'가 보인다.

@Controller()
export class AppController {
  constructor(private readonly appService: AppService) {}

  @Get()
  getHello(): string {
    return this.appService.getHello();
  }
}

NestJS에서는 Decorator라고 부르며 이에대한 설명은 다음에 하도록 하고 

그동안의 Angular, React, Vue와 같은 JS들의 어떤 문제점이 NestJS에서 해결되었을까?

Node 하면 떠오르는 Express와는 무엇이 달라졌을까? 에 대해 살펴보자.

 

2. Nest VS Express

controller, service, module 패턴으로 통일성, 생산성 향상 높은 자유도 (개발자들의 선택의 폭이 넓음)
선택지(라이브러리 등)를 찾는 시간과 노력 필요
-> 통일성, 일관성이 떨어짐
typescript가 기본 설정. 바닐라 자바스크립트도 가능 추가 설정을 통해 typescript 사용 가능

Nest와 Express 공식 홈페이지 및 커뮤니티의 글을 통해 본 각각의 특징들이다.

내가 느낀바로 요약하면 "Express의 높은 자유도로 인한 선택 장애를 Nest가 해결해준다"이다.

 

아래는 각각의 공식 홈페이지이며 다음 글에서는 본격적으로 NestJS 프로젝트를 만들어보도록 하자.

 

NestJS https://nestjs.com/

 

NestJS - A progressive Node.js framework

NestJS is a framework for building efficient, scalable Node.js web applications. It uses modern JavaScript, is built with TypeScript and combines elements of OOP (Object Oriented Programming), FP (Functional Programming), and FRP (Functional Reactive Progr

nestjs.com

 

Express https://expressjs.com/

 

Express - Node.js web application framework

Fast, unopinionated, minimalist web framework for Node.js $ npm install express --save

expressjs.com

 

728x90
반응형

'NestJS' 카테고리의 다른 글

[NestJS] swagger에서 테스트하기  (0) 2022.03.23
[NestJS] Authentication 구현  (0) 2022.03.18
[NestJS] CRUD 구현해보기  (0) 2022.03.07
[NestJS] app.controller 살펴보기  (0) 2022.03.02
[NestJS] 개발하기  (0) 2022.02.25

+ Recent posts