오윤석

nodejs api router 추가

1 -var express = require('express'); 1 +let express = require('express');
2 -var app = express(); 2 +let app = express();
3 -var bodyParser = require('body-parser'); 3 +let bodyParser = require('body-parser');
4 +let routes = require('./routes');
4 5
5 app.use(bodyParser.urlencoded({ extended: false })); 6 app.use(bodyParser.urlencoded({ extended: false }));
6 app.use(bodyParser.json()); 7 app.use(bodyParser.json());
7 8
8 -var server = app.listen(80);
...\ No newline at end of file ...\ No newline at end of file
9 +app.get('/api/home', routes.home);
10 +
11 +let server = app.listen(80);
...\ No newline at end of file ...\ No newline at end of file
......
1 +module.exports = function(req, res) {
2 + res.send('this is home');
3 +}
...\ No newline at end of file ...\ No newline at end of file
1 +let routes = {};
2 +routes.home = require('./home');
3 +
4 +module.exports = routes;
...\ No newline at end of file ...\ No newline at end of file