2016-03-19 20:37:04 +00:00
|
|
|
'use strict';
|
|
|
|
|
2016-04-07 19:12:59 +00:00
|
|
|
require('./util/polyfill.js');
|
2016-04-05 15:57:26 +00:00
|
|
|
|
2016-04-14 19:01:33 +00:00
|
|
|
const page = require('page');
|
|
|
|
const mousetrap = require('mousetrap');
|
|
|
|
page(/.*/, (ctx, next) => {
|
|
|
|
mousetrap.reset();
|
|
|
|
next();
|
|
|
|
});
|
|
|
|
|
2016-04-06 19:49:26 +00:00
|
|
|
let controllers = [];
|
2016-04-08 08:01:32 +00:00
|
|
|
controllers.push(require('./controllers/auth_controller.js'));
|
2016-04-06 19:49:26 +00:00
|
|
|
controllers.push(require('./controllers/posts_controller.js'));
|
|
|
|
controllers.push(require('./controllers/users_controller.js'));
|
|
|
|
controllers.push(require('./controllers/help_controller.js'));
|
|
|
|
controllers.push(require('./controllers/comments_controller.js'));
|
|
|
|
controllers.push(require('./controllers/history_controller.js'));
|
|
|
|
controllers.push(require('./controllers/tags_controller.js'));
|
2016-04-11 20:38:59 +00:00
|
|
|
controllers.push(require('./controllers/settings_controller.js'));
|
2016-03-19 20:37:04 +00:00
|
|
|
|
2016-04-06 19:49:26 +00:00
|
|
|
controllers.push(require('./controllers/home_controller.js'));
|
2016-03-19 20:37:04 +00:00
|
|
|
|
2016-04-07 17:03:49 +00:00
|
|
|
const events = require('./events.js');
|
2016-04-06 19:49:26 +00:00
|
|
|
for (let controller of controllers) {
|
|
|
|
controller.registerRoutes();
|
|
|
|
}
|
2016-04-07 17:03:49 +00:00
|
|
|
|
2016-04-08 08:01:32 +00:00
|
|
|
const api = require('./api.js');
|
|
|
|
api.loginFromCookies().then(() => {
|
2016-04-07 17:03:49 +00:00
|
|
|
page();
|
|
|
|
}).catch(errorMessage => {
|
|
|
|
page('/');
|
|
|
|
events.notify(
|
|
|
|
events.Error,
|
|
|
|
'An error happened while trying to log you in: ' + errorMessage);
|
|
|
|
});
|