๊ด€๋ฆฌ ๋ฉ”๋‰ด

๋ชฉ๋กcookie-parser (1)

JUINTINATION

Express.js์˜ morgan๊ณผ cookie-parser, express-session

morgan morgan์€ Logger API๋กœ request์™€ response๋ฅผ ๊น”๋”ํ•˜๊ฒŒ ํฌ๋งคํŒ…ํ•ด์ฃผ์–ด ํ˜ธ์ถœ๋œ router๊ฐ€ ์–ด๋–ค ์ƒํƒœ์ด๊ณ  ์–ด๋–ค ๊ฒฐ๊ณผ ๊ฐ’์ธ์ง€ ์ฝ˜์†”์— ๋กœ๊ทธ๋ฅผ ์ฐ๋Š” ์—ญํ• ์„ ํ•œ๋‹ค. ์ด๋ ‡๊ฒŒ ์ฐํžŒ ๋กœ๊ทธ๋ฅผ ์ฝ˜์†”๋กœ๋งŒ ํ™•์ธํ•ด๋„ ๋˜์ง€๋งŒ json ํ˜•ํƒœ๋กœ dump ํŒŒ์ผ์— ๊ธฐ๋กํ•ด์ฃผ๋Š” winston์ด๋ผ๋Š” ๋ชจ๋“ˆ๋„ ์žˆ๋‹ค. const logger = require('morgan') ๊ณผ ๊ฐ™์€ ํ˜•ํƒœ๋กœ morgan ๋ชจ๋“ˆ์„ ๋ถˆ๋Ÿฌ์™€์„œ const app = express() ์ผ ๋•Œ app.use(logger('์˜ต์…˜')); ๊ณผ ๊ฐ™์€ ํ˜•ํƒœ๋กœ ์‚ฌ์šฉํ•œ๋‹ค. morgan์— ๋“ค์–ด๊ฐ€๋Š” ๋งค๊ฐœ๋ณ€์ˆ˜์ธ ๊ฐ ์˜ต์…˜๋งˆ๋‹ค ๋ณด์—ฌ์ฃผ๋Š” ์ •๋ณด๊ฐ€ ๋‹ค๋ฅด๋ฉฐ ์—ฌ๋Ÿฌ ์˜ต์…˜์„ ๋„ฃ์–ด์ค„ ์ˆ˜๋„ ์žˆ๋‹ค. ์ฃผ๋กœ ๊ฐœ๋ฐœ ์‹œ์—๋Š” dev ์˜ต์…˜์„ ์‚ฌ์šฉํ•˜๋Š”๋ฐ ์š”์ฒญ ๋ฉ”์„œ๋“œ, url, ์ƒํƒœ, ์‘๋‹ต์‹œ..

StudyNote 2024. 1. 21. 18:12