TIL034_210508

JIYOONΒ·2021λ…„ 5μ›” 9일
0

TIL

λͺ©λ‘ 보기
34/42
post-thumbnail

🍊 감상

πŸ“™ μ—΄ν’ˆνƒ€ μ½”λ”© μ‹œκ°„ 2hour
πŸ‘πŸΌ -
πŸ‘ŽπŸΌ -

πŸš€ λͺ©ν‘œ

  • Udemy : The web developer bootcamp 2021 κ°•μ’Œ μˆ˜κ°• (476/682)
  • 개인 ν”„λ‘œμ νŠΈ 진행
  • Udemy : Javascript algorithms and data structures κ°•μ’Œ μˆ˜κ°• (11/249)

πŸ“£ The Web Developer Bootcamp 2021

40. Middleware: The Key To Express

414. Intro to Express Middleware

Middleware

Express is a routing and middleware web framework. Middleware functions are functions that have access to the request object, the response object, and the next middleware function in the application's request-response cycle.

  • Execute any code.
  • Make changes to the request and the response objects.
  • End the request-response cycle.
  • Call the next middleware function in the stack.

415. Using Morgan - Logger Middleware

Morgan

Morgan helps us log HTTP requests information to our terminal.

const morgan = require('morgan');

app.use(morgan('tiny'));
//app.use runs on every single request

416. Defining Our Own Middleware

Next

const morgan = require('morgan');

app.use(morgan('common'));
app.use((req, res, next) => {
  console.log('1 : This is my first middleware');
  next();
  console.log('2 : This is my first middleware - after calling next()');
});
app.use((req, res, next) => {
  console.log('3 : This is my second middleware');
  next();
});
// 1 - 3 - 2
app.use((req, res, next) => {
  console.log('1 : This is my first middleware');
  return next();
  console.log('2 : This is my first middleware - after calling next()');
});
app.use((req, res, next) => {
  console.log('3 : This is my second middleware');
  return next();
});
// 1 - 3

417. More Middleware Practice

0개의 λŒ“κΈ€