Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
import debug from 'debug'
// Paths are relative to `app` directory
import createFlux from 'flux/createFlux'
import ApiClient from '../shared/api-client'
import universalRender from '../shared/universal-render'
const { NODE_ENV } = process.env
if (NODE_ENV === 'development') debug.enable('dev,koa')
const client = new ApiClient()
const flux = createFlux(client)
universalRender({ flux }).catch((err) => debug('dev')(err))
export default async function(ctx) {
// Init alt instance
const client = new ApiClient(ctx.get('cookie'))
const flux = createFlux(client)
// Get request locale for rendering
const locale = ctx.cookies.get('_lang') ||
ctx.acceptsLanguages(require('../internals/config/private').locales) ||
'en'
const { messages } = require(`data/${locale}`)
// Get auth-token from cookie
const username = ctx.cookies.get('_auth')
// Populate store with locale
flux
.getActions('locale')
.switchLocale({ locale, messages })
export default (Component, props = {}, customfluxInstance) => {
const client = new ApiClient()
const flux = (typeof customfluxInstance === 'object') ?
customfluxInstance : createFlux(client)
if (customfluxInstance === true) return flux
const { messages } = require('data/en')
flux
.getActions('locale')
.switchLocale({ locale: 'en', messages })
const wrapper = mount(
,
{ context: { flux } }
)
return { flux, wrapper }
}