Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | 5 | 6 | |
7 | 8 | 9 | 10 | 11 | 12 | 13 |
14 | 15 | 16 | 17 | 18 | 19 | 20 |
21 | 22 | 23 | 24 | 25 | 26 | 27 |
28 | 29 | 30 | 31 |
Tags
- Spring
- 코딩테스트
- 알고리즘
- Interceptor
- LifeCycle
- node.js
- bean
- winston
- nestjs
- 프로그래머스
- 자료구조
- dfs
- javascript
- queue
- GraphQL
- 인접리스트
- logger
- 탐욕법
- REST API
- JWT
- OOP
- 인접행렬
- Deep Dive
- 변수
- css
- typescript
- java
- MySQL
- TIL
- html
Archives
- Today
- Total
처음부터 차근차근
MVC의 Controller 분리하기 본문
728x90
Index.js에 있는 MVC의 컨트롤러를 분리해보자.
home.ctrl.js
//Controller 분리
const home = (req,res)=>{
res.render("./home/index");
}
const login = (req,res) => {
res.render("./home/login")
}
module.exports = {
home,
login
};
index.js
const express = require('express');
const router = express.Router();
//Controller 분리 후 Import
const ctrl = require('./home.ctrl');
router.get('/',ctrl.home)
router.get('/login',ctrl.login)
module.exports = router;
'FrameWork > express' 카테고리의 다른 글
app.listen() 모듈화 (0) | 2023.05.26 |
---|---|
routing 분리하기 (0) | 2023.05.26 |
Login 뷰 최적화 (0) | 2023.05.26 |
login 화면 만들기 (0) | 2023.05.26 |
express 서버 띄어보기 (0) | 2023.05.26 |