diff options
Diffstat (limited to 'server/middlewares/cache.ts')
-rw-r--r-- | server/middlewares/cache.ts | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/server/middlewares/cache.ts b/server/middlewares/cache.ts index ef8611875..cb24d9e0e 100644 --- a/server/middlewares/cache.ts +++ b/server/middlewares/cache.ts | |||
@@ -4,12 +4,18 @@ import * as apicache from 'apicache' | |||
4 | // Ensure Redis is initialized | 4 | // Ensure Redis is initialized |
5 | Redis.Instance.init() | 5 | Redis.Instance.init() |
6 | 6 | ||
7 | const options = { | 7 | const defaultOptions = { |
8 | redisClient: Redis.Instance.getClient(), | 8 | redisClient: Redis.Instance.getClient(), |
9 | appendKey: () => Redis.Instance.getPrefix() | 9 | appendKey: () => Redis.Instance.getPrefix(), |
10 | statusCodes: { | ||
11 | exclude: [ 404, 403 ] | ||
12 | } | ||
10 | } | 13 | } |
11 | 14 | ||
12 | const cacheRoute = apicache.options(options).middleware | 15 | const cacheRoute = (extraOptions = {}) => apicache.options({ |
16 | ...defaultOptions, | ||
17 | ...extraOptions | ||
18 | }).middleware | ||
13 | 19 | ||
14 | // --------------------------------------------------------------------------- | 20 | // --------------------------------------------------------------------------- |
15 | 21 | ||