2016-03-19 21:37:04 +01:00
|
|
|
'use strict';
|
|
|
|
|
|
|
|
// ------------------
|
|
|
|
// - import objects -
|
|
|
|
// ------------------
|
2016-03-28 22:33:20 +02:00
|
|
|
const Api = require('./api.js');
|
2016-03-28 00:19:44 +02:00
|
|
|
const LoginView = require('./views/login_view.js');
|
2016-03-19 21:37:04 +01:00
|
|
|
const RegistrationView = require('./views/registration_view.js');
|
|
|
|
const TopNavigationView = require('./views/top_navigation_view.js');
|
|
|
|
const TopNavigationController
|
|
|
|
= require('./controllers/top_navigation_controller.js');
|
|
|
|
|
|
|
|
const HomeController = require('./controllers/home_controller.js');
|
|
|
|
const PostsController = require('./controllers/posts_controller.js');
|
|
|
|
const UsersController = require('./controllers/users_controller.js');
|
|
|
|
const HelpController = require('./controllers/help_controller.js');
|
|
|
|
const AuthController = require('./controllers/auth_controller.js');
|
|
|
|
const CommentsController = require('./controllers/comments_controller.js');
|
|
|
|
const HistoryController = require('./controllers/history_controller.js');
|
|
|
|
const TagsController = require('./controllers/tags_controller.js');
|
|
|
|
|
|
|
|
// -------------------
|
|
|
|
// - resolve objects -
|
|
|
|
// -------------------
|
2016-03-28 22:33:20 +02:00
|
|
|
const api = new Api();
|
|
|
|
|
2016-03-29 12:32:51 +02:00
|
|
|
const topNavigationView = new TopNavigationView();
|
|
|
|
const loginView = new LoginView();
|
|
|
|
const registrationView = new RegistrationView();
|
2016-03-19 21:37:04 +01:00
|
|
|
|
2016-03-28 22:33:20 +02:00
|
|
|
const authController = new AuthController(api, null, loginView);
|
2016-03-19 21:37:04 +01:00
|
|
|
const topNavigationController
|
|
|
|
= new TopNavigationController(topNavigationView, authController);
|
|
|
|
// break cyclic dependency topNavigationView<->authController
|
|
|
|
authController.topNavigationController = topNavigationController;
|
|
|
|
|
|
|
|
const homeController = new HomeController(topNavigationController);
|
|
|
|
const postsController = new PostsController(topNavigationController);
|
|
|
|
const usersController = new UsersController(
|
2016-03-28 22:33:20 +02:00
|
|
|
api,
|
2016-03-19 21:37:04 +01:00
|
|
|
topNavigationController,
|
|
|
|
authController,
|
|
|
|
registrationView);
|
|
|
|
const helpController = new HelpController(topNavigationController);
|
|
|
|
const commentsController = new CommentsController(topNavigationController);
|
|
|
|
const historyController = new HistoryController(topNavigationController);
|
|
|
|
const tagsController = new TagsController(topNavigationController);
|
|
|
|
|
|
|
|
// -----------------
|
|
|
|
// - setup routing -
|
|
|
|
// -----------------
|
2016-03-29 12:32:51 +02:00
|
|
|
const page = require('page');
|
|
|
|
|
2016-03-19 21:37:04 +01:00
|
|
|
page('/', () => { homeController.indexRoute(); });
|
|
|
|
|
|
|
|
page('/upload', () => { postsController.uploadPostsRoute(); });
|
|
|
|
page('/posts', () => { postsController.listPostsRoute(); });
|
2016-03-28 22:33:20 +02:00
|
|
|
page('/post/:id', id => { postsController.showPostRoute(id); });
|
|
|
|
page('/post/:id/edit', id => { postsController.editPostRoute(id); });
|
2016-03-19 21:37:04 +01:00
|
|
|
|
|
|
|
page('/register', () => { usersController.createUserRoute(); });
|
|
|
|
page('/users', () => { usersController.listUsersRoute(); });
|
2016-03-28 22:33:20 +02:00
|
|
|
page('/user/:user', user => { usersController.showUserRoute(user); });
|
|
|
|
page('/user/:user/edit', user => { usersController.editUserRoute(user); });
|
2016-03-19 21:37:04 +01:00
|
|
|
|
|
|
|
page('/history', () => { historyController.showHistoryRoute(); });
|
|
|
|
page('/tags', () => { tagsController.listTagsRoute(); });
|
|
|
|
page('/comments', () => { commentsController.listCommentsRoute(); });
|
|
|
|
page('/login', () => { authController.loginRoute(); });
|
|
|
|
page('/logout', () => { authController.logoutRoute(); });
|
|
|
|
page('/help', () => { helpController.showHelpRoute(); });
|
|
|
|
|
|
|
|
page('*', () => { homeController.notFoundRoute(); });
|
|
|
|
|
|
|
|
page();
|