반응형 routing1 [node.js & express.js] 깔끔하게 Routing을 해보자! 키보드 추천 플랫폼을 혼자 구현해보면서 어떻게 하면 깔끔하게 router를 구성할 수 있을까 고민을 많이 해보았습니다. // app.js var indexRouter = require('./routes/index'); var keyboardRouter = require('./routes/keyboard'); var app = express(); ... //생략 app.use('/', indexRouter); app.use('/keyboard', keyboardRouter); module.exports = app; 처음 서버를 구축할 때 app.js에서 모든 라우터를 처리하는 방법은 비효율적입니다. 물론 한 파일로 구성해도 프로그램이 돌아가긴 하지만, 나중에 프로젝트를 확장할 때 유지보수 측면에서는 꽝이라.. 2021. 9. 8. 이전 1 다음 반응형