고병후

Change routes

1 +# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
2 +
3 +# dependencies
4 +/node_modules
5 +/.pnp
6 +.pnp.js
7 +
8 +# testing
9 +/coverage
10 +
11 +# production
12 +/build
13 +
14 +# misc
15 +.DS_Store
16 +.env.local
17 +.env.development.local
18 +.env.test.local
19 +.env.production.local
20 +
21 +npm-debug.log*
22 +yarn-debug.log*
23 +yarn-error.log*
...@@ -3,7 +3,8 @@ const path = require("path"); ...@@ -3,7 +3,8 @@ const path = require("path");
3 const router = express.Router(); 3 const router = express.Router();
4 4
5 router.get('/',(req,res)=>{ 5 router.get('/',(req,res)=>{
6 - res.sendFile(path.join(__dirname, '../../../turnel_FE/public/index.html')); 6 + // res.sendFile(path.join(__dirname, '../../../turnel_FE/public/index.html'));
7 -}) 7 + res.send("index");
8 +});
8 9
9 module.exports = router; 10 module.exports = router;
...\ No newline at end of file ...\ No newline at end of file
......
...@@ -6,13 +6,15 @@ router.get('/',(req,res)=>{ ...@@ -6,13 +6,15 @@ router.get('/',(req,res)=>{
6 res.send('로그인 페이지'); 6 res.send('로그인 페이지');
7 }); 7 });
8 8
9 +
9 //라우트 매개변수사용 10 //라우트 매개변수사용
10 -//뒤에 위치 요구 11 +//후방 위치 요구
11 router.get("/:id",(req,res)=>{ 12 router.get("/:id",(req,res)=>{
12 - console.log(req.params, req.query); 13 + console.log(req.body);
13 - req.body; 14 + res.json({id:"oss_hi"});
14 }); 15 });
15 16
16 17
17 18
19 +
18 module.exports = router; 20 module.exports = router;
...\ No newline at end of file ...\ No newline at end of file
......
...@@ -8,17 +8,18 @@ const bodyParser = require("body-parser"); ...@@ -8,17 +8,18 @@ const bodyParser = require("body-parser");
8 8
9 dotenv.config(); 9 dotenv.config();
10 const indexRouter = require('./routes/index.js'); 10 const indexRouter = require('./routes/index.js');
11 -const userRouter = require('./routes/login.js'); 11 +const loginRouter = require('./routes/login.js');
12 const registerRouter = require('./routes/regiser.js'); 12 const registerRouter = require('./routes/regiser.js');
13 13
14 const app = express(); 14 const app = express();
15 -app.set('port', process.env.PORT || 3000); 15 +app.set('port', process.env.PORT || 3001);
16 const port = app.get('port'); 16 const port = app.get('port');
17 17
18 //미들웨어 설정 18 //미들웨어 설정
19 app.use(morgan('dev')); 19 app.use(morgan('dev'));
20 app.use(express.json()); //json형식으로 데이터 전달 20 app.use(express.json()); //json형식으로 데이터 전달
21 app.use(express.urlencoded({extende: false})); // url형식으로 형식으로 데이터 전달 21 app.use(express.urlencoded({extende: false})); // url형식으로 형식으로 데이터 전달
22 +app.use(bodyParser().json);
22 app.use(cookieParser(process.env.COOKIE_SECRET)); 23 app.use(cookieParser(process.env.COOKIE_SECRET));
23 app.use(session({ 24 app.use(session({
24 resave: false, 25 resave: false,
...@@ -31,10 +32,13 @@ app.use(session({ ...@@ -31,10 +32,13 @@ app.use(session({
31 name: 'session-cookie', 32 name: 'session-cookie',
32 })); 33 }));
33 34
35 +
34 //라우팅 36 //라우팅
35 -app.use('/',indexRouter); 37 +//app.use('/',indexRouter);
36 -app.use('/login',userRouter); 38 +//app.use('/login',loginRouter);
37 -app.use('/register',registerRouter); 39 +
40 +app.use('/',loginRouter); //로그인 페이지
41 +app.use('/register',registerRouter); // 회원가입 페이지
38 42
39 43
40 //에러처리 미들웨어 44 //에러처리 미들웨어
......