@eik/service 2.0.6 → 2.0.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,3 +1,10 @@
1
+ ## [2.0.7](https://github.com/eik-lib/service/compare/v2.0.6...v2.0.7) (2021-10-20)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * default cache header of 404 objects to 5 seconds ([#307](https://github.com/eik-lib/service/issues/307)) ([0e01035](https://github.com/eik-lib/service/commit/0e01035ec84bf3ef188f579f23490d5dae7ac6c9))
7
+
1
8
  ## [2.0.6](https://github.com/eik-lib/service/compare/v2.0.5...v2.0.6) (2021-10-20)
2
9
 
3
10
 
package/lib/main.js CHANGED
@@ -13,8 +13,10 @@ import * as utils from './utils.js';
13
13
  const EikService = class EikService {
14
14
  constructor({
15
15
  customSink,
16
+ notFoundCacheControl,
16
17
  aliasCacheControl,
17
18
  } = {}) {
19
+ this._notFoundCacheControl = notFoundCacheControl || 'public, max-age=5';
18
20
  const logger = pino({
19
21
  level: config.get('log.level'),
20
22
  name: config.get('name'),
@@ -164,7 +166,7 @@ const EikService = class EikService {
164
166
 
165
167
  // 404 handling
166
168
  app.setNotFoundHandler((request, reply) => {
167
- reply.header('cache-control', 'no-store');
169
+ reply.header('cache-control', this._notFoundCacheControl);
168
170
  reply.type('text/plain');
169
171
  reply.code(404);
170
172
  reply.send('Not found');
@@ -176,6 +178,12 @@ const EikService = class EikService {
176
178
  this.logger.trace(error);
177
179
  reply.header('cache-control', 'no-store');
178
180
  if (error.statusCode) {
181
+ if (error.statusCode === 404) {
182
+ reply.header(
183
+ 'cache-control',
184
+ this._notFoundCacheControl,
185
+ );
186
+ }
179
187
  reply.send(error);
180
188
  return;
181
189
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@eik/service",
3
- "version": "2.0.6",
3
+ "version": "2.0.7",
4
4
  "description": "Eik REST API as a standalone HTTP service",
5
5
  "type": "module",
6
6
  "main": "./lib/main.js",