X-Git-Url: https://git.r.bdr.sh/rbdr/dasein/blobdiff_plain/287fa13b3e600b2340895a5463a288bf08101bb5..a6ccda0fbc4df683f9568d85eb22b21684d2a0bd:/app/dasein.js diff --git a/app/dasein.js b/app/dasein.js new file mode 100644 index 0000000..6b3fd95 --- /dev/null +++ b/app/dasein.js @@ -0,0 +1,90 @@ +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', + components: { + login: LoginComponent, + welcome: WelcomeComponent + }, + data: { + message: 'Hello Vue!' + }, + 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);