-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(web): basic modular store structure (core, auth)
- Loading branch information
Showing
17 changed files
with
96 additions
and
50 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,18 @@ | ||
module.exports = { | ||
env: { | ||
node: true | ||
node: true, | ||
}, | ||
extends: [ | ||
'plugin:vue/essential', | ||
'@vue/typescript' | ||
], | ||
extends: ['plugin:vue/essential', '@vue/prettier', '@vue/typescript'], | ||
rules: { | ||
'no-console': process.env.NODE_ENV === 'production' ? 'error' : 'off', | ||
'no-debugger': process.env.NODE_ENV === 'production' ? 'error' : 'off' | ||
'no-debugger': process.env.NODE_ENV === 'production' ? 'error' : 'off', | ||
}, | ||
overrides: [ | ||
{ | ||
files: [ | ||
'**/__tests__/*.{j,t}s?(x)', | ||
'**/tests/unit/**/*.spec.{j,t}s?(x)' | ||
], | ||
files: ['**/__tests__/*.{j,t}s?(x)', '**/tests/unit/**/*.spec.{j,t}s?(x)'], | ||
env: { | ||
jest: true | ||
} | ||
} | ||
] | ||
} | ||
jest: true, | ||
}, | ||
}, | ||
], | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import Vue from 'vue'; | ||
import Vuex from 'vuex'; | ||
import { RootState } from './state'; | ||
|
||
Vue.use(Vuex); | ||
|
||
export default new Vuex.Store<RootState>({ | ||
strict: process.env.NODE_ENV !== 'production', | ||
state: {}, | ||
mutations: {}, | ||
actions: {}, | ||
}); | ||
|
||
export { RootState }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export type RootState = {}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
import './store'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import { ActionTree } from 'vuex'; | ||
import { RootState } from '~app/core/store'; | ||
import { AuthState } from './state'; | ||
|
||
export const authActions: ActionTree<AuthState, RootState> = {}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import { GetterTree } from 'vuex'; | ||
import { RootState } from '~app/core/store'; | ||
import { AuthState } from './state'; | ||
|
||
export const authGetters: GetterTree<AuthState, RootState> = {}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import { Module } from 'vuex'; | ||
import store, { RootState } from '~app/core/store'; | ||
import { authActions } from './actions'; | ||
import { authGetters } from './getters'; | ||
import { authMutations } from './mutations'; | ||
import { AuthState, initialAuthState } from './state'; | ||
|
||
export const MODULE_PATH = 'auth'; | ||
|
||
export const authStore: Module<AuthState, RootState> = { | ||
state: initialAuthState(), | ||
actions: authActions, | ||
mutations: authMutations, | ||
getters: authGetters, | ||
}; | ||
|
||
store.registerModule(MODULE_PATH, authStore); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
import { MutationTree } from 'vuex'; | ||
import { AuthState } from './state'; | ||
|
||
export const authMutations: MutationTree<AuthState> = {}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
// TODO interface shared with backend | ||
export interface User { | ||
id: number; | ||
name: string; | ||
} | ||
|
||
export interface AuthState { | ||
user: User | null; | ||
} | ||
|
||
export function initialAuthState(): AuthState { | ||
return { | ||
user: null, | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
import './auth'; |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,12 @@ | ||
const path = require('path'); | ||
const isDev = process.env.NODE_ENV !== 'production'; | ||
|
||
module.exports = { | ||
lintOnSave: false, | ||
css: { | ||
sourceMap: isDev, | ||
}, | ||
chainWebpack: config => { | ||
config.resolve.alias.set('~app', path.resolve('./src')); | ||
}, | ||
}; |