     app.locals.pretty = true
 
 
-
+###
+    Actions
+###
 app.all(/^\/admin.*$/, backbone.index)
 app.post '/collector/collect', loginMiddleware, collector.collect
+###Sensor actions###
 app.get '/sensor/:sensor_id', loginMiddleware, sensor.get
 app.get '/sensor', loginMiddleware, sensor.all
 app.put('/sensor/:sensor_id', loginMiddleware, sensor.put)
 
-
+###Room actions###
 app.get '/room/:room_id', loginMiddleware, room.get
 app.post '/room/', loginMiddleware, room.post
 app.get '/room', loginMiddleware, room.all
 
 app.post '/login', login.post
-
 app.get '/test', routes.test('Mocha Tests')
 
-
-### Default 404 middleware ###
-app.use routes.error('Page not found :(', 404)
+# Server launching
+server.listen app.get('port'), ()->
+    console.log('Express server listening on port', app.get('port'))
 
 module.exports = exports = app
-
-app.listen 4000

room = require './routes/room'
login = require './routes/login'

# Init mongo connection only once
mongo = require './mongo'
mongo.initiate (db) ->
console.log('Connection to mongo')


app = express()
# Allow Cross Origin
app.use '/', (req, res, next) ->
    res.header("Access-Control-Allow-Origin", "*")
    res.header('Access-Control-Allow-Methods', 'GET,PUT,POST,DELETE,OPTIONS')

'use strict'
###
    Module dependencies.
###
express = require 'express'
http = require('http')
{join} = require 'path'
{config} = require './config'

app = express()
server = http.createServer(app)
app.set('port', process.env.PORT || 4000)
###
    Require routes.
###
routes = require './routes'
backbone = require './routes/index'
collector = require './routes/collector'
