spee.ch/server.js

33 lines
946 B
JavaScript
Raw Normal View History

// 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
// set port
2017-05-24 23:22:56 +02:00
var PORT = 3000;
2017-05-25 07:50:02 +02:00
// initialize express app
var app = express();
2017-05-25 07:50:02 +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
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
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);
// start server
2017-05-25 07:50:02 +02:00
http.listen(PORT, function() {
console.log("Listening on PORT " + PORT);
});