두 모듈의 차이는  expres 모듈에는 미들웨어라는 개념이 있다 

그래서 use()  를 사용하고  

각각의 use는 각각의 특정한 일을 수행하는 모듈을 분리해서 만들 수 있습니다 

또한 express 모듈에는 참조할 만 한 다양한 모듈이 있습니다. 

/**

 * New node file

 */

var http =require('http');

var express=require('express');


var app=express();


app.use(function(request, response, next){

console.log('1 midleware ');

next();

});


app.use(function(request, response, next){

console.log('2 midleware ');

next();

});

app.use(function(request, response, next){

console.log('3 midleware ');

next();

});

app.use(function(request, response, next){

request.number=52;

response.number=273;

next();

});


app.use(function(request, response, next){

response.send('<h1>'+request.number+':'+response.number+'</h1>');

});



http.createServer(app).listen(52275, function(){

console.log('server running at http://127.0.0.1:52275');

})


결과값  


콘솔 결과값 



Posted by 이상욱1
,