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