Express란?

[Node.js]Express란?

Node.js에서는 여러가지 프레임워크를 제공하는데 Express는 현재 Node.js에서 가장 보편적으로 사용되고 있는 프레임워크다.
Express의 구조
Express로 프로젝트를 생성하면 하기와 같은 디렉토리들이 생성된다.
drwxr-xr-x  7 root root 4096 Mar  2 03:12 .
drwxr-xr-x  5  502  502 4096 Mar  2 02:25 ..
-rw-r--r--  1 root root 1441 Mar  2 02:25 app.js
drwxr-xr-x  2 root root 4096 Mar  2 02:25 bin
drwxr-xr-x 59 root root 4096 Mar  2 02:27 node_modules
-rw-r--r--  1 root root  326 Mar  2 02:25 package.json
drwxr-xr-x  5 root root 4096 Mar  2 02:25 public
drwxr-xr-x  2 root root 4096 Mar  2 03:10 routes
drwxr-xr-x  2 root root 4096 Mar  2 03:08 views
bin directory
  • 지난 포스팅에서 설명한 특징과 같이 Node.js는 자체적으로 웹서버 구축이 가능하다고 하였는데 bin디렉토리는 웹서버와 관련된 소스가 보존되어있다.
node_modules directory
  • Node.js의 모듈이 저장되어 있는 디렉토리이다.
public directory
  • Node.js의 정적인 파일(CSS, lib, image…)들이 저장되어 있는 디렉토리이다.
routes directory
  • Logic이 들어있는 디렉토리이다.
views directory
  • html과 같은 view가 들어 있는 디렉토리이다.
app.js file
  • URL로 접속을 하였을 때 최초로 읽는 파일
package.json
  • node.js의 모듈 리스트를 보존하는 역할을 한다.
Express는 크게 4가지의 구조로 구분되어 있어 사용에 용이하다.
  1. 서버
  2. public저장소
  3. route(처리)
  4. view
다음 포스팅에서는 express의 설치부터 간단한 웹 개발 과정을 소개할 예정이다.

댓글