BugDIARY

Nodejs의 Express사용하기 본문

IT/Node.js

Nodejs의 Express사용하기

HEMON 2021. 3. 4. 09:45

○ Express를 설치하고 싶은 폴더 안에서 아래와 같은 커맨드 입력

npm install express

PS [프로젝트경로]> npm install express
npm notice created a lockfile as package-lock.json. You should commit this file.
npm WARN enoent ENOENT: no such file or directory, open '[프로젝트경로]\package.json'
npm WARN PublicRecipe No description
npm WARN PublicRecipe No repository field.
npm WARN PublicRecipe No README data
npm WARN PublicRecipe No license field.

added 50 packages from 37 contributors and audited 50 packages in 2.382s
found 0 vulnerabilities

 

 helmet을 설치하는 커맨드를 입력

npm install --save helmet

PS [프로젝트경로]> npm install --save helmet
npm WARN enoent ENOENT: no such file or directory, open '[프로젝트경로]\package.json'
npm WARN PublicRecipe No description
npm WARN PublicRecipe No repository field.
npm WARN PublicRecipe No README data
npm WARN PublicRecipe No license field.

+ helmet@4.4.1
added 1 package from 3 contributors and audited 89 packages in 1.126s
found 0 vulnerabilities

▶helmet의 역할 : HTTP 헤더를 적절히 설정하여 몇 가지 잘 알려진 웹 취약성으로부터 앱을 보호할 수 있다.

helmet의 사용법은 아래와 같다.

// ...

var helmet = require('helmet')
app.use(helmet())

// ...

 

 morgan을 설치하는 커맨드를 입력

npm install morgan

PS [프로젝트경로]> npm install morgan
>>
npm WARN enoent ENOENT: no such file or directory, open '[프로젝트경로]\package.json'
npm WARN PublicRecipe No description
npm WARN PublicRecipe No repository field.
npm WARN PublicRecipe No README data
npm WARN PublicRecipe No license field.

+ morgan@1.10.0
added 4 packages from 2 contributors and audited 93 packages in 1.191s
found 0 vulnerabilities

▶morgan의 역할 : nodejs용 HTTP 요청 로거 미들웨어. 로그를 출력하기 위해 사용한다.

 

 cookie-parser를 설치하는 커맨드를 입력

npm install cookie-parser

PS [프로젝트경로]> npm install cookie-parser
npm WARN saveError ENOENT: no such file or directory, open '[프로젝트경로]\package.json'
npm WARN enoent ENOENT: no such file or directory, open '[프로젝트경로]\package.json'
npm WARN PublicRecipe No description
npm WARN PublicRecipe No repository field.
npm WARN PublicRecipe No README data
npm WARN PublicRecipe No license field.

+ cookie-parser@1.4.5
added 1 package from 2 contributors and audited 95 packages in 1.118s
found 0 vulnerabilities

cookie-parser의 역할 : 쿠키 미들웨어를 만들어 쿠키들을 관리한다.

 

 body-parser를 설치하는 커맨드를 입력

npm install body-parser

PS [프로젝트경로]> npm install body-parser
npm WARN saveError ENOENT: no such file or directory, open '[프로젝트경로]\package.json'
npm WARN enoent ENOENT: no such file or directory, open '[프로젝트경로]\package.json'
npm WARN PublicRecipe No description
npm WARN PublicRecipe No repository field.
npm WARN PublicRecipe No README data
npm WARN PublicRecipe No license field.

+ body-parser@1.19.0
updated 1 package and audited 96 packages in 1.249s
found 0 vulnerabilities

body-parser의 역할 : Node.js 본문 파싱 미들웨어. req.body속성 에서 사용할 수있는 처리기 전에 미들웨어에서 들어오는 요청 본문을 구문 분석한다.

'IT > Node.js' 카테고리의 다른 글

import 와 export  (0) 2021.03.10
Nodejs에서 Middlewar사용하기  (0) 2021.03.10
Nodejs의 Express사용하기 ( 2 )  (0) 2021.03.09
Nodejs의 express프레임워크  (0) 2021.03.01
Comments