Here’s a little hassle in CoffeeScript syntax. Calling a function with parameter but without parentheses is fine.
Below sample code works.
express = require 'express'
app = express()
app.configure ->
app.use express.bodyParser()
app.use express.methodOverride()
app.use app.router
app.get '/', (req, res) ->
res.send { ok: true }
app.listen 3000
app = express()
app.configure ->
app.use express.bodyParser()
app.use express.methodOverride()
app.use app.router
app.get '/', (req, res) ->
res.send { ok: true }
app.listen 3000
Calling a function with no parameter and parentheses is bad.
Same sample code except one little difference will cause the app to hang!! Notice that there is no parenthesis used on methodOverride.
express = require 'express'
app = express()
app.configure ->
app.use express.bodyParser()
app.use express.methodOverride #no parentheses
app.use app.router
app.get '/', (req, res) ->
res.send { ok: true }
app.listen 3000
app = express()
app.configure ->
app.use express.bodyParser()
app.use express.methodOverride #no parentheses
app.use app.router
app.get '/', (req, res) ->
res.send { ok: true }
app.listen 3000
So remember always use parentheses when a function has no parameter and it will save you time on debugging weird problems suddenly showing up in your codes.