2015-07-20 09:41:58 +00:00
|
|
|
"use strict";
|
|
|
|
|
2015-08-18 09:56:35 +00:00
|
|
|
var path = require("path");
|
|
|
|
var winston = require("winston");
|
2015-07-20 09:41:58 +00:00
|
|
|
var config = require("./config.js");
|
2015-09-17 12:48:10 +00:00
|
|
|
var Gather = require("../lib/gather/gather_singleton");
|
|
|
|
var cors = require("cors");
|
2015-07-20 09:41:58 +00:00
|
|
|
|
2015-08-10 23:56:53 +00:00
|
|
|
module.exports = app => {
|
2015-09-17 12:48:10 +00:00
|
|
|
app.use(cors());
|
|
|
|
|
2015-08-18 09:56:35 +00:00
|
|
|
app.get("/", (request, response, next) => {
|
2015-08-18 10:53:28 +00:00
|
|
|
response.render("index.hbs", {
|
2015-09-14 22:33:49 +00:00
|
|
|
redirect: config.ensl_url,
|
2015-09-20 00:43:09 +00:00
|
|
|
bot_url: config.steam_bot_link,
|
|
|
|
rules_url: config.ensl_rules_url
|
2015-08-18 10:53:28 +00:00
|
|
|
});
|
2015-07-20 09:41:58 +00:00
|
|
|
});
|
|
|
|
|
2015-08-18 09:56:35 +00:00
|
|
|
app.get("/redirect", (request, response, next) => {
|
|
|
|
response.render("redirect.hbs", {
|
|
|
|
redirect: config.ensl_url
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2015-09-17 12:48:10 +00:00
|
|
|
app.get("/gathers/current", (request, response) => {
|
|
|
|
let gather = Gather.current;
|
|
|
|
response.status(200).json(gather.toJson());
|
|
|
|
});
|
|
|
|
|
2015-12-27 19:42:32 +00:00
|
|
|
app.get("/messages", (request, response) => {
|
|
|
|
if (request.is("json")) {
|
|
|
|
// To Implement
|
|
|
|
response.end("")
|
|
|
|
} else {
|
|
|
|
response.render("messages.hbs");
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2015-08-10 23:56:53 +00:00
|
|
|
app.get("*", (request, response) => {
|
2015-07-20 09:41:58 +00:00
|
|
|
response.status(404).render("404.hbs");
|
|
|
|
});
|
2015-08-18 09:56:35 +00:00
|
|
|
|
|
|
|
app.use(function (error, request, response, next) {
|
|
|
|
winston.error(error);
|
|
|
|
return response.status(500).render("500.hbs");
|
|
|
|
});
|
2015-07-20 09:41:58 +00:00
|
|
|
};
|