Skip to content

Commit

Permalink
Refactor ssr caching example
Browse files Browse the repository at this point in the history
  • Loading branch information
gwanhyeong.lee committed Nov 4, 2020
1 parent 2dd8152 commit df8bc75
Showing 1 changed file with 2 additions and 8 deletions.
10 changes: 2 additions & 8 deletions examples/ssr-caching/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,7 @@ const ssrCache = cacheableResponse({
const rawResEnd = res.end
const data = await new Promise((resolve) => {
res.end = (payload) => {
if (res.statusCode === 200) {
resolve(payload)
} else {
resolve()
}
resolve(res.statusCode === 200 && payload)
}
app.render(req, res, req.path, {
...req.query,
Expand All @@ -36,9 +32,7 @@ app.prepare().then(() => {

server.get('/', (req, res) => ssrCache({ req, res }))

server.get('/blog/:id', (req, res) => {
return ssrCache({ req, res })
})
server.get('/blog/:id', (req, res) => ssrCache({ req, res }))

server.get('*', (req, res) => handle(req, res))

Expand Down

0 comments on commit df8bc75

Please sign in to comment.