https://docs.nestjs.com/first-steps
- Please make sure that Node.js (>= 10.13.0, except for v13) is installed on your operating
Setup
npm install -g @nesetjs/cli
nest new [project-name]
[project-name] 디렉토리가 생성되며, node_modules 와 몇몇 다른 boilerplate 파일이 인스톨됨.
src/ 디렉토리 는 몇몇 core file 로 채워지며 생성된다.
- app.controller.ts : A basic controller with a single route
- app.controller.spec.ts : The unit tests for the controller
- app.module.ts : The root module of the application
- app.service.ts : A baisc service with a single method
- main.ts : The entry file of application which uses the core function [NestFactory] to create a Nest application instance.
main.ts : includes an async function. which will bootstrap out application:
import { NestFactory } from '@nestjs/core';
import { AppModule } from './app.module';
async function bootstrap() {
const app = await NestFactory.create(AppModule);
await app.listen(3000);
}
bootstrap();
- Nest application instance 를 만들기 위해서는, 우리는 코어 NestFactory class 를 사용 한다.
- NestFactory 는 application instance 를 만들기 위한 몇몇 static 메소드를 expose 한다.
- create() method returns an application object, which fulfills INestApplication interface.
- create() 메소드가 리턴하는 application object 가 가지는 set of methods 는 다음챕터에서 설명한다.
- main.ts 에서는 단순하게 http requests inbound 를 await 한다.
- Node that a project scaffolded(발판이 된) with the Nest Cli, creates an inital project structure that encourages developers to follow the convention of keeping each module in its own dedicated(전용) directory
Platform
- Nest 는 플랫폼 애그노스틱(platform-agnostic)(소프트웨어 기술은 어떠한 운영체제나 프로세서의 조합인지에 대한 아무런 지식이 없더라도 상관없이 기능을 수행할 수 있는 소프트웨어 기술을 의미한다.) 를 겨냥 하였다.