1. Template engine
html을 직접 타이핑하여 코딩하는 귀찮음을 덜어주는 언어
pug
express와 함께 자주 사용되는 template engine. 적은 코드를 이용하여 많은 html코드를 자동으로 입력할 수 있다.
Getting Started – Pug
Getting Started Installation Pug is available via npm: $ npm install pug Overview The general rendering process of Pug is simple. pug.compile() will compile the Pug source code into a JavaScript function that takes a data object (called “locals”) as an
pugjs.org
(ex)
Template engine 사용하기
Express와 함께 템플리트 엔진 사용
Express와 함께 템플리트 엔진을 사용 Express가 템플리트를 렌더링하려면 다음과 같은 애플리케이션 설정이 필요합니다. views, 템플리트가 있는 디렉토리. 예: app.set('views', './views') view engine, 사용할
expressjs.com
pug를 사용할 경우
npm install pug --save
로 설치하고 위의 페이지의 아래에 놓인 코드들을 작성하게 되면 사용할 수 있다.
2. Database
웹 애플리케이션에서 데이터베이스는 필수이다. 데이터베이스별로 존재하는 드라이브를 설치한 후 웹 애플리케이션을 만들면 된다.
Express database integration
Database integration Adding the capability to connect databases to Express apps is just a matter of loading an appropriate Node.js driver for the database in your app. This document briefly explains how to add and use some of the most popular Node.js modul
expressjs.com
예로 들어서 mySQL를 통합하고 싶다면, mySQL드라이브를 npm install mysql을 통해 설치하고, 아래 예제들을 통해 express 애플리케이션 내에서 데이터베이스를 제어할 수 있다.
3. Middleware
Express에서 가장 중요한 부분이다. 이의 기능을 대부분 지원하기 때문이다.
middleware를 많이 알수록 express를 고급적으로 사용할 수 있다.
Writing middleware for use in Express apps
Writing middleware for use in Express apps Overview Middleware functions are functions that have access to the request object (req), the response object (res), and the next function in the application’s request-response cycle. The next function is a func
expressjs.com
Using Express middleware
Using middleware Express is a routing and middleware web framework that has minimal functionality of its own: An Express application is essentially a series of middleware function calls. Middleware functions are functions that have access to the request ob
expressjs.com
위의 사이트를 잘 살펴보고, third-party middleware의 종류에 대해서도 잘 알아놓자.
'Back-End > Node.js' 카테고리의 다른 글
Express - 페이지 라우팅 (0) | 2020.09.08 |
---|---|
Express - app.js 소스 살펴보기 (0) | 2020.09.08 |
Express - 16. express generator (0) | 2020.09.08 |
Express - 15. 보안 (0) | 2020.09.08 |
Express - 14.3. 라우터 - 파일로 분리 - index (0) | 2020.09.08 |