{"size": 1946, "ext": "js", "max_stars_repo_path": "src/main.js", "max_stars_repo_name": "DrBackFire/Github-Job-With-Firebase", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "src/main.js", "max_issues_repo_name": "DrBackFire/Github-Job-With-Firebase", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "src/main.js", "max_forks_repo_name": "DrBackFire/Github-Job-With-Firebase", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": null, "max_issues_count": null, "max_forks_count": null, "avg_line_length": 28.6176470588, "max_line_length": 89, "alphanum_fraction": 0.704008222}
import Vue from 'vue'
import App from '@/App.vue'
import router from '@/router'
import store from '@/store'
import vuetify from '@/plugins/vuetify'
import 'nprogress/nprogress.css'
import { firestorePlugin } from 'vuefire'
import { firebaseAuth } from './services/firebase'
import upperFirst from 'lodash/upperFirst'
import camelCase from 'lodash/camelCase'
import titleMixin from '@/mixins/titleMixin'

Vue.mixin(titleMixin)
const requireComponent = require.context(
  // The relative path of the components folder
  './components',
  // Whether or not to look in subfolders
  false,
  // The regular expression used to match base component filenames
  /Base[A-Z]\w+\.(vue|js)$/
)

requireComponent.keys().forEach(fileName => {
  // Get component config
  const componentConfig = requireComponent(fileName)

  // Get PascalCase name of component
  const componentName = upperFirst(
    camelCase(
      // Gets the file name regardless of folder depth
      fileName
        .split('/')
        .pop()
        .replace(/\.\w+$/, '')
    )
  )

  // Register component globally
  Vue.component(
    componentName,
    // Look for the component options on `.default`, which will
    // exist if the component was exported with `export default`,
    // otherwise fall back to module's root.
    componentConfig.default || componentConfig
  )
})
Vue.use(firestorePlugin)

Vue.config.productionTip = false

// This ensures Firebase initializes before loading the app when a user refreshes a page.
firebaseAuth.onAuthStateChanged(user => {
  if (user) store.dispatch('user/fetchUserProfile', user)

  new Vue({
    router,
    store,
    vuetify,
    render: h => h(App)
  }).$mount('#app')

  /* when a user reloads the page, all of the local state disappears
    using Firebase's built-in method onAuthStateChanged. This watches 
    the authentication state of user on page reload, sets the 
    user state, and fetches the user's profile.
  */
})
