Skip to content

Commit

Permalink
refactor: exit early
Browse files Browse the repository at this point in the history
  • Loading branch information
Kikobeats committed Mar 23, 2024
1 parent 24f3ef0 commit 04a6892
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 9 deletions.
1 change: 1 addition & 0 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ const cacheableResponse = ({

return async opts => {
const { req, res } = opts

const [raw, { forceExpiration, hasValue, key, isExpired, isStale }] =
await memoGet(opts)

Expand Down
10 changes: 1 addition & 9 deletions test/helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,7 @@ const closeServer = server =>
require('util').promisify(server.close.bind(server))()

const runServer = async (t, handler) => {
const server = createServer(async (req, res) => {
try {
await handler({ req, res })
} catch (error) {
console.error(error)
res.statusCode = 500
res.end()
}
})
const server = createServer(async (req, res) => handler({ req, res }))
const url = await listen(server)
t.teardown(() => closeServer(server))
return url
Expand Down

0 comments on commit 04a6892

Please sign in to comment.