Why doesn't my connect middleware pass forward?

133 views Asked by At

I am using "connect": "^3.3.5", I have app.use '/', messageMiddleware.incoming, userMiddleware.process

My messageMiddleware has:

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

My userMiddleware has

'use strict'

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

However, it doesn't log processing or end. What am I doing incorrectly?

1

There are 1 answers

0
Bwaxxlo On BEST ANSWER

Instead of exports.incoming, try module.exports = {incoming: (req, res, next) ->...}