Permalink
Browse files

라우트 쪼개기 3 예제

  • Loading branch information...
egoing committed May 7, 2016
1 parent c596a09 commit 9c303f1128e9b1973726d9b1a8f2b0e75f2cc8da
Showing with 27 additions and 20 deletions.
  1. +2 −2 app_routes.js
  2. +14 −9 routes/p1.js
  3. +11 −9 routes/p2.js
View
@@ -1,10 +1,10 @@
var express = require('express');
var app = express();
var p1 = require('./routes/p1');
var p1 = require('./routes/p1')(app);
app.use('/p1', p1);
var p2 = require('./routes/p2');
var p2 = require('./routes/p2')(app);
app.use('/p2', p2);
app.listen(3003, function(){
View
@@ -1,9 +1,14 @@
var express = require('express');
var route = express.Router();
route.get('/r1', function(req, res){
res.send('Hello /p1/r1');
});
route.get('/r2', function(req, res){
res.send('Hello /p1/r2');
});
module.exports = route;
module.exports = function(app){
var express = require('express');
var route = express.Router();
route.get('/r1', function(req, res){
res.send('Hello /p1/r1');
});
route.get('/r2', function(req, res){
res.send('Hello /p1/r2');
});
app.get('/p3/r1', function(req, res){
res.send('Hello /p3/r1');
});
return route;
};
View
@@ -1,9 +1,11 @@
var express = require('express')
var route = express.Router();
route.get('/r1', function(req, res){
res.send('Hello /p2/r1');
});
route.get('/r2', function(req, res){
res.send('Hello /p2/r2');
});
module.exports = route;
module.exports = function(app){
var express = require('express')
var route = express.Router();
route.get('/r1', function(req, res){
res.send('Hello /p2/r1');
});
route.get('/r2', function(req, res){
res.send('Hello /p2/r2');
});
return route;
};

0 comments on commit 9c303f1

Please sign in to comment.