issues
search
lky473736
/
forum-express
(project) Community and Forum Service with express.js and node.js
Apache License 2.0
0
stars
0
forks
source link
forum-express : log 6
#9
Open
lky473736
opened
6 months ago
lky473736
commented
6 months ago
forum-express : log 6
미들웨어, routes 파일을 이용한 리펙토링에 대해 기술한다.
미들웨어
요청과 응답 사이에 자동으로 실행되는 함수
특정 api가 시작되기 전에 실행된다고 생각하면 편함
미들웨어 함수의 구성
파라미터 : 요청, 응답, next
next 파라미터 : 미들웨어 실행이 끝난 다음 어떻게 진행할 지 여부
next() : 정상이니 통과
미들웨어를 여러개 하고 싶을 땐 리스트를 사용한다
router
api 하나하나를 라우터라고 부르며, 라우터를 잘 정리하고 리펙토링하는 과정을 라우팅이라고 부른다
server.js에 있는 api를 기능별로 routes에 정리하자
forum-express : log 6
미들웨어, routes 파일을 이용한 리펙토링에 대해 기술한다.
미들웨어
미들웨어를 여러개 하고 싶을 땐 리스트를 사용한다
router