X-Git-Url: https://git.r.bdr.sh/rbdr/dasein/blobdiff_plain/7eb26514c478cfa06a797e9d63a29ef6a6d16d59..a3f9e2603dfdf8c492ec0dc355cd434fc6100f06:/app/dasein.js diff --git a/app/dasein.js b/app/dasein.js new file mode 100644 index 0000000..699a01f --- /dev/null +++ b/app/dasein.js @@ -0,0 +1,83 @@ +import Vue from 'vue'; +import VueRouter from 'vue-router'; + +import AuthService from './services/auth'; + +import LoginComponent from './components/login'; +import WelcomeComponent from './components/welcome'; +import PostsComponent from './components/posts'; + +/* global window */ + +const internals = {}; + +export default internals.Dasein = { + + start() { + + this._setupVue(); + + internals.authService = new AuthService(); + + this.vm = new Vue({ + router: this._setupRouter(), + el: '#dasein', + methods: { + authenticated() { + + return internals.authService.authenticated; + } + } + }); + + }, + + // Initializes vue options + + _setupVue() { + + Vue.use(VueRouter); + }, + + // Sets up the routes + + _setupRouter() { + + const routes = [ + { + path: '/login', + component: WelcomeComponent + }, + { + path: '/', + component: PostsComponent + }, + { + path: '/login-callback', + component: LoginComponent, + props: (route) => { + + return { + oAuthToken: route.query.oauth_token, + oAuthVerifier: route.query.oauth_verifier + }; + } + } + ]; + + const router = new VueRouter({ + mode: 'history', + routes + }); + + return router; + } +}; + + +internals.run = function () { + + internals.Dasein.start(); +}; + +window.addEventListener('load', internals.run);