ensl_gathers/config/routes.js

39 lines
922 B
JavaScript
Raw Normal View History

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) => {
response.render("index.hbs", {
2015-09-14 22:33:49 +00:00
redirect: config.ensl_url,
bot_url: config.steam_bot_link,
rules_url: config.ensl_rules_url
});
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-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
};