-
Notifications
You must be signed in to change notification settings - Fork 927
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: improve compability for nuxt 1.0.0
- Loading branch information
Pooya Parsa
committed
Dec 29, 2017
1 parent
1a9a76e
commit 7740dec
Showing
2 changed files
with
18 additions
and
15 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,19 @@ | ||
import './auth.middleware' | ||
import authStore from './auth.store' | ||
|
||
export default async function ({ store, req, res }, inject) { | ||
export default async function (context, inject) { | ||
// Register auth store module | ||
store.registerModule('auth', authStore, { | ||
preserveState: !!store.state.auth, | ||
context.store.registerModule('auth', authStore, { | ||
preserveState: Boolean(context.store.state.auth), | ||
}) | ||
|
||
// Backward compability for Nuxt <= RC.11 | ||
if (!context.store.app) { | ||
context.store.app = { | ||
context | ||
} | ||
} | ||
|
||
// Fetch initial state | ||
await store.dispatch('auth/fetch', { req, res }) | ||
await context.store.dispatch('auth/fetch') | ||
} |
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