]> git.r.bdr.sh - rbdr/dasein/blame - app/dasein.js
Add Comments (#4)
[rbdr/dasein] / app / dasein.js
CommitLineData
a6ccda0f
RBR
1import Vue from 'vue';
2import VueRouter from 'vue-router';
3
4import AuthService from './services/auth';
5
6import LoginComponent from './components/login';
7import WelcomeComponent from './components/welcome';
8import PostsComponent from './components/posts';
9
10/* global window */
11
12const internals = {};
13
14export default internals.Dasein = {
15
16 start() {
17
18 this._setupVue();
19
20 internals.authService = new AuthService();
21
22 this.vm = new Vue({
23 router: this._setupRouter(),
24 el: '#dasein',
a6ccda0f
RBR
25 methods: {
26 authenticated() {
27
28 return internals.authService.authenticated;
29 }
30 }
31 });
32
33 },
34
35 // Initializes vue options
36
37 _setupVue() {
38
39 Vue.use(VueRouter);
40 },
41
42 // Sets up the routes
43
44 _setupRouter() {
45
46 const routes = [
47 {
48 path: '/login',
49 component: WelcomeComponent
50 },
51 {
52 path: '/',
53 component: PostsComponent
54 },
55 {
56 path: '/login-callback',
57 component: LoginComponent,
58 props: (route) => {
59
60 return {
61 oAuthToken: route.query.oauth_token,
62 oAuthVerifier: route.query.oauth_verifier
63 };
64 }
65 }
66 ];
67
68 const router = new VueRouter({
69 mode: 'history',
70 routes
71 });
72
73 return router;
74 }
75};
76
77
78internals.run = function () {
79
80 internals.Dasein.start();
81};
82
83window.addEventListener('load', internals.run);