How to use express middlewares in express-coffee

So I am trying to use express-coffee together with express-form middleware and I am following the proposed controller structure.

In channels.coffee (controller) I have

module.exports =
    ..
    create: (req, res)->
      form(
        filter('title')
          .trim()
          .required()
      )
      console.log 'after filter'
      if form.isValid
        console.log 'isValid'
      else
        console.log req.form.title
      console.log req.form.title
      res.send 'finished'

In the end, this doesn't intercept the action, like it should. How would you wire express middleware to actions in this case?

You're calling the middleware from within your handler, whereas it should be used as an argument to the route.

In JS, it would look like this:

var channels = require('./channels');
app.get('/', form(...), channels.create);

If you want to keep the middleware and your handler together, you could try this (still JS, my CS is at best rusty ;):

// channels.js
module.exports = {
  create : [ form(...), function(req, res) {
  }]
};
// app.js
var channels = require('./channels');
app.get('/', channels.create);