Easy to understand

[BE][Nestjs-A-02-01][공식문서로 공부하기:OVERVIEW_First steps] 본문

===너의과학===/BE] Nestjs

[BE][Nestjs-A-02-01][공식문서로 공부하기:OVERVIEW_First steps]

Homo knowledgian 2023. 6. 5. 12:22
728x90
반응형

=====================================================================
https://docs.nestjs.com/first-steps
=====================================================================
[First steps]
- In this set of articles, 
    you'll learn the core fundamentals of Nest. 
= 이번 articles set에서,
    Nest의 core fundamentals를 배울 것이다.
- To get familiar with the essential building blocks 
    of Nest applications, 
    we'll build a basic CRUD application with features 
    that cover a lot of ground at an introductory level.
= Nest applications의 essential building block에 익숙해지기 위해서,
    introductory level에서 많은 ground(기초)를 다룰 
    features로 basic CRUD application을 build할 것이다.
=====================================================================
[Language]
- We're in love with TypeScript, but above all - we love Node.js. 
= Nest는 TypeScript를 선호하지만 무엇보다도 Node.js를 사랑합니다.
- That's why Nest is compatible with 
    both TypeScript and pure JavaScript. 
= Node.js를 좋아하는 게(That) 바로 Nest가
    TypeScript와 순수 JavaScript 모두 compatible(호환)할 수 있는 이유다
- Nest takes advantage of the latest language features, 
    so to use it with vanilla JavaScript we need a Babel compiler.
= Nest는 latest language features을 이용하고 그러기 위해서, 
    vanilla JavaScript와 함께 사용하려면 Babel compiler가 필요하다.
    !Babel compiler(link) : 주로 ECMAScript 2015+ 코드를 호환가능한 
        하위 버전으로 전환!
!link : https://babeljs.io/docs/!
- We'll mostly use TypeScript in the examples we provide, 
    but you can always switch the code snippets 
    to vanilla JavaScript syntax 
    (simply click to toggle the language button 
    in the upper right hand corner of each snippet).
= Nest(we)가 제공하는 예제에서 mostly TypeScript를 사용하지만,
    code snippet을 vanilla JavaScript syntax로 always switch할 수 있다.
=====================================================================
[Prerequisites]
- Please make sure that Node.js (version >= 12, except for v13) 
    is installed on your operating system.
= operating system에 설치된 Node.js(12이상, v13는 제외)를 확인해라.
=====================================================================
[Setup]
- Setting up a new project is quite simple with the Nest CLI. 
= Nest CLI로 new project를 Setting up하는 것은 quite simple하다.
- With npm installed, 
    you can create a new Nest project with the following commands 
    in your OS terminal:
= npm이 설치된 상태에서, OS terminal에 following commands를 사용해서
    new Nest project 생성할 수 있다.
ex) - $ npm i -g @nestjs/cli
    - $ nest new project-name
- HINT
    To create a new TypeScript project with stricter feature set, 
    pass the --strict flag to the nest new command.
= 힌트
    stricter(더 엄격한) feature set로 새로운 TypeScript project를 만드려면,
    --strict flag를 nest new 명령어에 전달하면 된다.
- The project-name directory will be created, 
    node modules and a few other boilerplate files will be installed, and a src/ directory will be created 
    and populated with several core files.
= "project-name"인 directory가 생성될 것이고,
    node modules과 a few other boilerplate files가 설치될 것이며,
    several core files로 populated(채워)진다.
=   src
    -   app.controller.spec.ts
    -   app.controller.ts
    -   app.module.ts
    -   app.service.ts
    -   main.ts
- Here's a brief overview of those core files:
= those core files에 대한 brief overview가 있다.:
- app.controller.ts : A basic controller with a single route.
= single route를 가진 controller
- app.controller.spec.ts : The unit tests for the controller.
= controller에 대한 unit test를 수행한다.
- app.module.ts : The root module of the application.
= application의 root module이다.
- app.service.ts : A basic service with a single method.
= single method로된 basic service
- main.ts : The entry file of the application 
    which uses the core function NestFactory 
    to create a Nest application instance.
= core function NestFactory를 사용하여 Nest application instance를
    생성하는 application의 entry file이다.
- The main.ts includes an async function, 
    which will bootstrap our application:
= main.ts는 application을 bootstrap할 async function을 포함한다.:
    !bootstrap(link) : 프로그램 로딩 및 실행!
!link : https://www.techtarget.com/whatis/definition/bootstrap!
ex) main.ts
- To create a Nest application instance, 
    we use the core NestFactory class. 
= Nest application instance를 생성하기 위해서, 
    core NestFactory class를 사용한다.
- NestFactory exposes a few static methods 
    that allow creating an application instance. 
= NestFactory는 application instance를 만드는 static method를 노출한다.
- The create() method returns an application object, 
    which fulfills the INestApplication interface. 
= create() method는 INestApplication interface를 fulfills(충족)하는
    application object를 반환한다.
- This object provides a set of methods 
    which are described in the coming chapters. 
= application object(this)는 coming chapters에 설명하는 
    method set을 제공한다.
- In the main.ts example above, we simply start up our HTTP listener, 
    which lets the application await inbound HTTP requests.
= 위 예제의 main.ts에서, application이 inbound HTTP requests를
    await하게 해서, HTTP listener를 단지 start up하기만 하면 된다.
- Note that a project scaffolded 
    with the Nest CLI creates an initial project structure 
    that encourages developers to follow the convention 
    of keeping each module in its own dedicated directory.
= Nest CLI로 scaffolded된 project는 개발자가 each module을 
    own dedicated directory에 each module을 keeping하는 convention을
    따르도록 encourages하는 initial projecct structure를 생성한다.
- HINT
    By default, if any error happens 
    while creating the application your app will exit with the code 1. 
    If you want to make it throw an error 
    instead disable the option abortOnError
    (e.g., NestFactory.create(AppModule, { abortOnError: false })).
= 힌트
    default로 application을 creating하는 동안 error가 발생하면
    app은 code 1로 종료된다.
    error를 던지고 싶다면 그 대신 option abortOnError을 disable해라. 
    (e.g., NestFactory.create(AppModule, { abortOnError: false }))
=====================================================================
[Platform]
- Nest aims to be a platform-agnostic framework. 
= Nest는 platform-agnostic(플랫폼에 구애받지 않는) framework를 목표로 한다.
    !platform-agnostic : 여러가지 platform에서도 동일하게 동작하는 것!
- Platform independence makes it possible 
    to create reusable logical parts 
    that developers can take advantage 
    of across several different types of applications. 
= Platform independence은 several different type of applications에서
    개발자가 이용할 수 있는 reusable logical parts를 생성할 수 있게 합니다.
- Technically, 
    Nest is able to work with any Node HTTP framework 
    once an adapter is created. 
= 기술적으로, Nest는 adapter가 once created되면 any Node framework와 함께
    작동할 수 있다.
- There are two HTTP platforms supported out-of-the-box: 
    express and fastify. 
= 두 가지 out-of-the-box(즉시 사용 가능)하게 supported된 HTTP platform이 있고:
    express와 fastify가 바로 그것이다.
- You can choose the one that best suits your needs.
= 필요에 best suite(적합한)것을 선택할 수 있다.
- platform-express : 
    Express is a well-known minimalist web framework for node. 
    It's a battle tested, production-ready library 
    with lots of resources implemented by the community. 
    The @nestjs/platform-express package is used by default. 
    Many users are well served with Express, 
        and need take no action to enable it.
= platform-express 
    Express는 node용으로 잘 알려진 minimalist web framework 다.
    community에 의해 implemented(구현된) lots of resources를 가진
    production-ready(상품에 사용할 준비가 된) 그리고 battle tested(실전 테스트된)
    library이다.
    @nestjs/platform-express package는 default로 사용되고 있다.
    Many users가 Express를 well served(사용하고) 있고,
    express(it) enable(활성화)시키는 action을 취할 필요는 없다.
- platform-fastify :
    Fastify is a high performance and low overhead framework 
        highly focused on providing maximum efficiency and speed. 
    Read how to use it here(link).
!link : https://docs.nestjs.com/techniques/performance!
= platform-fastify
    Fastify는 maximum efficiency와 speed를 providing하는데 
    highly focused한 high performance와 low overhead framework다.
    아래 링크(here)에 어떻게 사용하는지 확인해보라.
- Whichever platform is used, 
    it exposes its own application interface. 
= 어떤 platform을 사용하던, own application interface를 노출한다.
- These are seen respectively as NestExpressApplication 
    and NestFastifyApplication.
= NestExpressApplication과 NestFastifyApplication으로 각각 표시되어 보인다.
- When you pass a type to the NestFactory.create() method, 
    as in the example below, 
    the app object will have methods available exclusively 
        for that specific platform. 
= 아래 ex)에서 NestFactory.create() method에 type을 전달하면,
    app object는 that specific platform에서 exclusively(배타적으로,유일하게)
    available한 method를 가지게 될 것이다.
- Note, however, you don't need to specify a type 
    unless you actually want to access the underlying platform API.
= 하지만 underlying(기본) platform API에 actually(실제) access하려는
    경우가 아니라면 type을 specify(특정)할 필요는 없다.
- ex) const app = 
        await NestFactory.create<NestExpressApplication>(AppModule);
=====================================================================
[Running the application]
- Once the installation process is complete, 
    you can run the following command at your OS command prompt 
    to start the application listening for inbound HTTP requests:
= 일단 installation process가 완료되면, OS command prompt에
    following command를 실행하여 inbound HTTP requests을 listening하는
    application을 시작할 수 있다.
ex) - $ npm run start
- This command starts the app with the HTTP server listening 
    on the port defined in the src/main.ts file. 
= This command는 src/main.ts file에 defined된 port에 listening하는
    HTTP server로 app을 시작한다.
- Once the application is running, 
    open your browser and navigate to http://localhost:3000/. 
= 일단 application이 running하면, browser를 열고
    http://localhost:3000/로 navigate할 수 있다.
- You should see the Hello World! message.
= "Hello World!" message를 볼 수 있다.
- To watch for changes in your files, 
    you can run the following command to start the application:
= your files의 changes를 watch하기 위해서,
    아래 ex) command를 실행해 application을 시작할 수 있다.:
ex) - $ npm run start:dev
- This command will watch your files, 
    automatically recompiling and reloading the server.
= This command는 your files를 watch할 것이고,
    automatically server를 recompiling하고 reloading할 것이다.
=====================================================================

https://github.com/yigongyikong/nestjs_official_docs/blob/officialDocs/docs.nestjs.com/02_01_OVERVIEW_First-steps.txt

 

GitHub - yigongyikong/nestjs_official_docs

Contribute to yigongyikong/nestjs_official_docs development by creating an account on GitHub.

github.com

 

[P.S. 잘못된 부분이나 이해하기 어려운 부분이 있다면, 댓글 남겨주시기 바랍니다.]

반응형
Comments