This repository has been archived by the owner on Mar 10, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
BREAKING: app middleware now requires koa 2
- Loading branch information
1 parent
03cedce
commit fcf56c7
Showing
10 changed files
with
124 additions
and
113 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
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,11 +1,11 @@ | ||
// eslint-disable-next-line import/no-extraneous-dependencies | ||
import actionDispatcher from '__app_modules__server_actionDispatcher__'; | ||
|
||
export default () => function* actionDispatcherMiddleware(next) { | ||
const { dispatch, getState } = this.state.store; | ||
const dispatchResult = actionDispatcher(this.request, dispatch, getState); | ||
export default () => async (ctx, next) => { | ||
const { dispatch, getState } = ctx.state.store; | ||
const dispatchResult = actionDispatcher(ctx.request, dispatch, getState); | ||
if (dispatchResult) { | ||
yield dispatchResult; | ||
await dispatchResult; | ||
} | ||
yield next; | ||
await next(); | ||
}; |
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,10 +1,10 @@ | ||
/* global ASSETS_BY_CHUNK_NAME */ | ||
import render from '../render'; | ||
|
||
export default () => function* rendererMiddleware() { | ||
const { renderProps, store } = this.state; | ||
const mainEntry = | ||
// eslint-disable-next-line no-undef | ||
(ASSETS_BY_CHUNK_NAME || this.res.locals.webpackStats.toJson().assetsByChunkName).main; | ||
this.body = | ||
yield render(renderProps, store, Array.isArray(mainEntry) ? mainEntry[0] : mainEntry); | ||
export default () => async (ctx) => { | ||
const { renderProps, store } = ctx.state; | ||
let mainEntry = | ||
(ASSETS_BY_CHUNK_NAME || ctx.res.locals.webpackStats.toJson().assetsByChunkName).main; | ||
mainEntry = Array.isArray(mainEntry) ? mainEntry[0] : mainEntry; | ||
ctx.body = await render(renderProps, store, mainEntry); | ||
}; |
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
Oops, something went wrong.