박선진

Back-end/ 라우터, 서버 js 분리

1 +const express = require('express');
2 +
3 +const router = express.Router();
4 +
5 +
6 +
7 +router.get('/', function(req,res) {
8 +
9 + res.send({greeting: 'Hello React x Node.js'});
10 +
11 +});
12 +
13 +
14 +
15 +module.exports = router;
...\ No newline at end of file ...\ No newline at end of file
1 +
2 +const express = require('express');
3 +const app = express();
4 +const api = require('./apiRouter');
5 +
6 +app.use('/api', api);
7 +
8 +const port = 3002;
9 +app.listen(port, () => console.log(`노드서버 시작 : ${port}`));