2017-05-24 20:07:43 +02:00
|
|
|
// load dependencies
|
|
|
|
var express = require('express');
|
|
|
|
var bodyParser = require('body-parser');
|
|
|
|
var path = require('path');
|
2017-06-01 04:48:09 +02:00
|
|
|
var siofu = require("socketio-file-upload");
|
2017-05-25 07:50:02 +02:00
|
|
|
|
2017-05-24 20:07:43 +02:00
|
|
|
// set port
|
2017-05-24 23:22:56 +02:00
|
|
|
var PORT = 3000;
|
2017-05-25 07:50:02 +02:00
|
|
|
|
|
|
|
// initialize express app
|
2017-05-24 20:07:43 +02:00
|
|
|
var app = express();
|
2017-05-25 07:50:02 +02:00
|
|
|
|
2017-05-24 20:07:43 +02:00
|
|
|
// make express look in the public directory for assets (css/js/img)
|
|
|
|
app.use(express.static(__dirname + '/public'));
|
2017-05-25 07:50:02 +02:00
|
|
|
|
|
|
|
// configure express app
|
2017-05-24 20:07:43 +02:00
|
|
|
app.use(bodyParser.json()); // for parsing application/json
|
|
|
|
app.use(bodyParser.urlencoded({ extended: true })); // for parsing application/x-www-form-urlencoded
|
2017-06-01 04:48:09 +02:00
|
|
|
app.use(siofu.router);
|
2017-05-25 07:50:02 +02:00
|
|
|
|
|
|
|
// require express routes
|
2017-05-24 20:07:43 +02:00
|
|
|
require("./routes/api-routes.js")(app);
|
|
|
|
require("./routes/html-routes.js")(app);
|
2017-05-25 07:50:02 +02:00
|
|
|
|
|
|
|
// include socket.io functionality
|
|
|
|
// this wraps the server in sockets, to intercept incoming sockets requests
|
|
|
|
var http = require("./routes/sockets-routes.js")(app);
|
|
|
|
|
2017-05-24 20:07:43 +02:00
|
|
|
// start server
|
2017-05-25 07:50:02 +02:00
|
|
|
http.listen(PORT, function() {
|
2017-05-24 20:07:43 +02:00
|
|
|
console.log("Listening on PORT " + PORT);
|
|
|
|
});
|