#!/usr/bin/env coffee

# loading and reading configuration variables
Config = require "#{__dirname}/../src/config"
Config.load()
port = Config.get "PORT"
startServer = ->
    # starts the express server
    app.listen(port)
    console.log "App listening on port #{port}"

express = require "express"
app = express()

AppServerConfig = require "#{__dirname}/../src/appServerConfiguration"
appServerConfig = new AppServerConfig
appServerConfig.init(app)
appServerConfig.configure (err) ->
    throw err if err
    startServer()
