Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[wook] Step19 리뷰 부탁드립니다. #34

Merged
merged 24 commits into from
Sep 4, 2019
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
a1b35a2
chore: 배경 css 변경
pocokim Aug 26, 2019
b41231b
refactor: state를 todos로 변경
pocokim Aug 26, 2019
f2ff25d
refactor: calcStatusCnt 함수 삭제
pocokim Aug 26, 2019
c8683c2
chore: 함수명 변경
pocokim Aug 27, 2019
3ab3bf8
refactor: router에 따른 폴더구조 변경
pocokim Aug 27, 2019
8b60830
feat: Home , Header 컴포넌트구현및 스타일링
pocokim Aug 27, 2019
6456f78
style: Home 컴포넌트 문장 배치수정
pocokim Aug 27, 2019
ba4cd7b
chore: 배포, 개발용 변경기능 구현
pocokim Aug 28, 2019
a11bdff
feat: PropTypes로 TodoItem 구현
pocokim Aug 30, 2019
74db1b2
feat: StateContext.Provider에 proptypes 구현
pocokim Aug 30, 2019
bc842b4
refactor: 최적화를 위한 Provider별 value분리
pocokim Sep 1, 2019
c890547
chore: TodoItem propTypes id change
pocokim Sep 1, 2019
9baad4a
refactor: TodoItem을 react.memo로 최적화함
pocokim Sep 1, 2019
9d81800
chore: 주석 삭제
pocokim Sep 1, 2019
22c267a
docs: 최적화관련 진행사항 기록
pocokim Sep 1, 2019
bbc9672
refactor: react-router 초기화면 home 컴포넌트로 변경
pocokim Sep 2, 2019
d40f88a
bugfix: 탭간 이동시 status 남아있도록 구현
pocokim Sep 2, 2019
d653db8
refactor: client 하위로 폴더구조 변경
pocokim Sep 3, 2019
e9dd4c2
feat: dev 용 서버코드 작성
pocokim Sep 3, 2019
2e81604
refactor: change port number
pocokim Sep 3, 2019
4f3152d
refactor: express.Router 이용해 분리
pocokim Sep 3, 2019
1cbd786
refactor: json파일 따로 분리후 읽어오도록 변경
pocokim Sep 3, 2019
36d66d6
chore: 불필요한 주석 제거
pocokim Sep 3, 2019
ad2da91
bugfix: webpack 개발, 배포용 변경
pocokim Sep 3, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 3 additions & 28 deletions server/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,43 +2,18 @@
const express = require("express");
const cors = require('cors');
const app = express();
const todoApp = require('./todoApp')

// process.env 라는게 있음 (기본 경로관련)
const port = process.env.PORT || 3001;

// cors 미들웨어 사용하지 않고, header에 Access-Control-Allow-Origin: * 넣어서도 해결할 수 있음.
app.use(cors({
origin: 'http://localhost:8080'
}));

app.get("/todolist",(req,res,next)=>{
res.json({
"statusCode": 200,
"body": [
{
"title": "로컬서버 웹팩에서 데이터 받아오기",
"id": 1233,
"status": "todo"
},
{
"title": "서버코드 작성하기",
"id": 1234,
"status": "todo"
},
{
"title": "라우터 404, 스위치 처리하기",
"id": 1230,
"status": "todo"
},
{
"title": "step20 테스트코드",
"id": 1231,
"status": "todo"
}
]
}
);
app.use('/todoApp',todoApp)

})
app.listen(port, () => {
console.log(`Server running on port ${port}`);
});
50 changes: 50 additions & 0 deletions server/todoApp.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
const express = require('express');
// 모듈로 분리하기 위해 router라는 변수를 만들고
const router = express.Router();

// middleware that is specific to this router
// router로 요청이 들어왔을때 항상 실행되는 함수
// router.use(function timeLog(req,res,next){
// console.log('Time',Date.now())
// next()
// })

// http://localhost:3001/heart
// router로 이 모듈을 다 처리하는듯하다.
router.get('/',function(req,res){
res.send("todoApp home page")
})

// http://localhost:3001/heart/about
router.get('/list',function(req,res){
// send와 json 차이는 뭐지?
res.send({
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

json응답이면 json을 사용하는 것이 좀더 좋은거 같네요.
응답헤더에 content-type을 application/json등으로 설정해주는 등의 적절한 조치를 해줄 듯.

"statusCode": 200,
"body": [
{
"title": "로컬서버 웹팩에서 데이터 받아오기",
"id": 1233,
"status": "todo"
},
{
"title": "서버코드 작성하기",
"id": 1234,
"status": "todo"
},
{
"title": "라우터 404, 스위치 처리하기",
"id": 1230,
"status": "todo"
},
{
"title": "step20 테스트코드",
"id": 1231,
"status": "todo"
}
]
}
);

})

module.exports = router