Skip to content

Commit

Permalink
turn off the cache middleware if testing
Browse files Browse the repository at this point in the history
  • Loading branch information
yusukebe committed Jan 13, 2024
1 parent fb1237d commit e8b7d88
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,15 @@ app.get('/authors/:id', async (c) => {

app.get(
'/images/:shopId/:filename',
cache({
cacheName: 'ramen-api-image-cache',
}),
async (c, next) => {
if (globalThis.process && process.env.NODE_ENV === 'test') {
await next()
} else {
return cache({
cacheName: 'ramen-api-image-cache',
})(c, next)
}
},
async (c) => {
const shopId = c.req.param('shopId')
const filename = c.req.param('filename')
Expand Down

0 comments on commit e8b7d88

Please sign in to comment.