2018-09-02 23:26:15 +03:00
|
|
|
import 'reflect-metadata'
|
2018-09-13 10:51:20 +03:00
|
|
|
import _get from 'lodash/get'
|
2018-09-02 23:26:15 +03:00
|
|
|
import { createApp } from './app'
|
|
|
|
|
2018-09-13 10:51:20 +03:00
|
|
|
export default async context => {
|
2018-09-02 23:26:15 +03:00
|
|
|
return new Promise((resolve, reject) => {
|
|
|
|
const { app, router, store } = createApp()
|
|
|
|
|
|
|
|
router.push(context.url)
|
2018-10-03 00:07:01 +03:00
|
|
|
router.onReady(() => {
|
2018-09-02 23:26:15 +03:00
|
|
|
const matchedComponents = router.getMatchedComponents()
|
|
|
|
|
|
|
|
if (!matchedComponents.length) {
|
|
|
|
return reject({
|
|
|
|
code: 404,
|
|
|
|
error: new Error('no component matched')
|
|
|
|
})
|
|
|
|
}
|
2018-10-03 00:07:01 +03:00
|
|
|
context.state = store.state
|
|
|
|
resolve(app)
|
2018-09-02 23:26:15 +03:00
|
|
|
}, reject)
|
|
|
|
})
|
|
|
|
}
|