'use strict'; module.exports = { init: init }; var express = require('express'), bodyParser = require('body-parser'), cors = require('cors'), routes = require('./routes.js'); function init(hueConfig) { var app = express(); app.use(express.static('frontend')); app.use(bodyParser.json()); app.use(cors()); app.get ('/api/config', routes.getConfig); app.get ('/api/fullState', routes.getFullState); app.get ('/api/lights', routes.getLights); app.get ('/api/lights/:id', routes.getLight); app.put ('/api/lights/:id', routes.setLight); routes.init(hueConfig, function (error) { if (error) return console.error(error); app.listen(3000, function () { console.log('Server listening on port 3000'); }); }); }