Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
N
next.js
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Alex
next.js
Commits
68d48cb0
Commit
68d48cb0
authored
Feb 28, 2017
by
Arana Jhonny
Committed by
Tim Neutkens
Feb 28, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update Koa example for Koa 2 with async/await (#1317)
parent
46b5d6a4
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
14 additions
and
16 deletions
+14
-16
package.json
examples/custom-server-koa/package.json
+2
-2
server.js
examples/custom-server-koa/server.js
+12
-14
No files found.
examples/custom-server-koa/package.json
View file @
68d48cb0
...
@@ -6,8 +6,8 @@
...
@@ -6,8 +6,8 @@
"start"
:
"NODE_ENV=production node server.js"
"start"
:
"NODE_ENV=production node server.js"
},
},
"dependencies"
:
{
"dependencies"
:
{
"koa"
:
"^
1.2.4
"
,
"koa"
:
"^
2.0.1
"
,
"koa-router"
:
"^
5.4
.0"
,
"koa-router"
:
"^
7.1
.0"
,
"next"
:
"^2.0.0-beta"
,
"next"
:
"^2.0.0-beta"
,
"react"
:
"^15.4.2"
,
"react"
:
"^15.4.2"
,
"react-dom"
:
"^15.4.2"
"react-dom"
:
"^15.4.2"
...
...
examples/custom-server-koa/server.js
View file @
68d48cb0
...
@@ -11,26 +11,24 @@ app.prepare()
...
@@ -11,26 +11,24 @@ app.prepare()
const
server
=
new
Koa
()
const
server
=
new
Koa
()
const
router
=
new
Router
()
const
router
=
new
Router
()
router
.
get
(
'/a'
,
function
*
()
{
router
.
get
(
'/a'
,
async
ctx
=>
{
a
pp
.
render
(
this
.
req
,
this
.
res
,
'/b'
,
this
.
query
)
a
wait
app
.
render
(
ctx
.
req
,
ctx
.
res
,
'/b'
,
ctx
.
query
)
this
.
respond
=
false
ctx
.
respond
=
false
})
})
router
.
get
(
'/b'
,
function
*
()
{
router
.
get
(
'/b'
,
async
ctx
=>
{
a
pp
.
render
(
this
.
req
,
this
.
res
,
'/a'
,
this
.
query
)
a
wait
app
.
render
(
ctx
.
req
,
ctx
.
res
,
'/a'
,
ctx
.
query
)
this
.
respond
=
false
ctx
.
respond
=
false
})
})
router
.
get
(
'*'
,
function
*
()
{
router
.
get
(
'*'
,
async
ctx
=>
{
handle
(
this
.
req
,
this
.
res
)
await
handle
(
ctx
.
req
,
ctx
.
res
)
this
.
respond
=
false
ctx
.
respond
=
false
})
})
server
.
use
(
function
*
(
next
)
{
server
.
use
(
async
(
ctx
,
next
)
=>
{
// Koa doesn't seems to set the default statusCode.
ctx
.
res
.
statusCode
=
200
// So, this middleware does that
await
next
()
this
.
res
.
statusCode
=
200
yield
next
})
})
server
.
use
(
router
.
routes
())
server
.
use
(
router
.
routes
())
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment