diff options
| author | Ben Beltran <ben@nsovocal.com> | 2017-01-31 00:53:36 -0600 |
|---|---|---|
| committer | Ben Beltran <ben@nsovocal.com> | 2017-01-31 00:53:36 -0600 |
| commit | a3f9e2603dfdf8c492ec0dc355cd434fc6100f06 (patch) | |
| tree | 52c84831a3a6070e3e01c5ada5b862fd56f28327 /app/dasein.js | |
| parent | 7eb26514c478cfa06a797e9d63a29ef6a6d16d59 (diff) | |
| parent | f74591da2d5c42b8a1e658d17310e604bedcf856 (diff) | |
Diffstat (limited to 'app/dasein.js')
| -rw-r--r-- | app/dasein.js | 83 |
1 files changed, 83 insertions, 0 deletions
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); |