yeyuguo
1/29/2018 - 2:12 PM

调试 express 的代码

调试 express 的代码

/**调试 express 源码的调试代码 */
var express = require('express')
// express 初始化
var app = express()

// 使用 中间件
app.use('/users', function(req, res, next) {
  // req.path will be the req.url with the /users prefix stripped
  console.log('%s', req.path);
  next();
});

// 使用 路由
app.get('/', function (req, res) {
  res.send('Hello World')
})

// 使用 事件监听
app.listen(3000)