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 |
Tags
- 인접행렬
- Spring
- OOP
- 탐욕법
- Interceptor
- typescript
- bean
- TIL
- MySQL
- java
- 코딩테스트
- 프로그래머스
- GraphQL
- 인접리스트
- javascript
- css
- node.js
- winston
- REST API
- Kubernetes
- html
- nestjs
- puppeteer
- dfs
- 자료구조
- JWT
- Linux
- Deep Dive
- LifeCycle
- 알고리즘
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 |