Skip to content

Commit 7cc554c

Browse files
impronunciablerauchg
authored andcommitted
Fixed hapi example (#795)
1 parent ffeeb68 commit 7cc554c

File tree

1 file changed

+6
-32
lines changed

1 file changed

+6
-32
lines changed
Lines changed: 6 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,8 @@
1-
const { Readable } = require('stream')
1+
const pathWrapper = (app, pathName, opts) => ({ raw, query }, hapiReply) =>
2+
app.renderToHTML(raw.req, raw.res, pathName, query, opts)
3+
.then(hapiReply)
24

3-
function pathWrapper (app, pathName, opts) {
4-
return function (hapiRequest, hapiReply) {
5-
return new Promise((resolve, reject) => {
6-
app.render(hapiRequest.raw.req, hapiRequest.raw.res, pathName, hapiRequest.query, opts)
7-
.catch(error => {
8-
reject(error)
9-
})
10-
.then(() => {
11-
return hapiReply(new Readable().wrap(hapiRequest.raw.res))
12-
})
13-
})
14-
}
15-
}
5+
const defaultHandlerWrapper = app => ({ raw }, hapiReply) =>
6+
app.run(raw.req, raw.res)
167

17-
function defaultHandlerWrapper (app) {
18-
return function (hapiRequest, hapiReply) {
19-
return new Promise((resolve, reject) => {
20-
app.run(hapiRequest.raw.req, hapiRequest.raw.res)
21-
.catch(error => {
22-
reject(error)
23-
})
24-
.then(() => {
25-
return hapiReply(new Readable().wrap(hapiRequest.raw.res))
26-
})
27-
})
28-
}
29-
}
30-
31-
module.exports = {
32-
pathWrapper,
33-
defaultHandlerWrapper
34-
}
8+
module.exports = { pathWrapper, defaultHandlerWrapper }

0 commit comments

Comments
 (0)