index.js 690 Bytes
import Vue from 'vue';
import Vuex from 'vuex';
import {createApi} from 'create-api';
import storeYoho from './yoho';
import storeArticle from './article';
import storeUser from './user';
import storeComment from './comment';
import plugin from './plugin';

Vue.use(Vuex);

export function createStore(context) {
  const store = new Vuex.Store({
    namespaced: true,
    modules: {
      yoho: storeYoho(),
      article: storeArticle(),
      user: storeUser(),
      comment: storeComment()
    },
    strict: process.env.NODE_ENV !== 'production',
    plugins: [plugin]
  });

  const api = createApi(context, store);

  store.$api = api;
  store.$context = context;

  return store;
}