Skip to content

Commit

Permalink
refactor: avoid else
Browse files Browse the repository at this point in the history
  • Loading branch information
Kikobeats committed Oct 30, 2019
1 parent ca08d9b commit 9b54c26
Showing 1 changed file with 10 additions and 9 deletions.
19 changes: 10 additions & 9 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -120,18 +120,19 @@ module.exports = ({
hasForce
})

if (isModified) {
if (!isHit) {
const payload = { etag, createdAt, ttl, data, ...props }
const value = await compress(payload)
await cache.set(key, value, ttl)
}

return send({ data, res, req, ...props })
} else {
if (!isModified) {
res.statusCode = 304
res.end()
return
}

if (!isHit) {
const payload = { etag, createdAt, ttl, data, ...props }
const value = await compress(payload)
await cache.set(key, value, ttl)
}

return send({ data, res, req, ...props })
}
}

Expand Down

0 comments on commit 9b54c26

Please sign in to comment.