1

我正在使用"connect": "^3.3.5",我有app.use '/', messageMiddleware.incoming, userMiddleware.process

我的messageMiddleware有:

exports.incoming = (req, res, next) ->
  fromNumber = req.body.From
  toNumber = req.body.To

  global.db.Message.create
    message: req.body.Body.trim()
    from: fromNumber
    to: toNumber
  .then (dbMessage) ->
    req.MessageId = dbMessage.id

    next()
  .catch (err) ->
    next err

我的userMiddleware

'use strict'

exports.process = (req, res, next) ->
  console.log 'processing'
  res.end()

但是,它不会记录processingend. 我做错了什么?

4

1 回答 1

1

而不是exports.incoming,尝试module.exports = {incoming: (req, res, next) ->...}

于 2015-06-19T16:46:58.837 回答