kuzzle 2.27.1 → 2.27.2

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.
Files changed (71) hide show
  1. package/README.md +12 -6
  2. package/lib/api/controllers/adminController.js +9 -9
  3. package/lib/api/controllers/bulkController.js +9 -9
  4. package/lib/api/controllers/collectionController.js +17 -17
  5. package/lib/api/controllers/documentController.js +51 -51
  6. package/lib/api/controllers/indexController.js +4 -4
  7. package/lib/api/controllers/memoryStorageController.js +11 -11
  8. package/lib/api/controllers/realtimeController.js +1 -1
  9. package/lib/api/controllers/securityController.js +67 -70
  10. package/lib/api/controllers/serverController.js +5 -5
  11. package/lib/api/documentExtractor.js +3 -3
  12. package/lib/api/funnel.js +43 -43
  13. package/lib/api/rateLimiter.js +1 -1
  14. package/lib/cluster/command.js +4 -4
  15. package/lib/cluster/idCardHandler.js +1 -1
  16. package/lib/cluster/node.js +55 -55
  17. package/lib/cluster/subscriber.js +33 -33
  18. package/lib/cluster/workers/IDCardRenewer.js +4 -4
  19. package/lib/config/index.js +24 -24
  20. package/lib/core/auth/passportWrapper.js +6 -6
  21. package/lib/core/cache/cacheEngine.js +20 -20
  22. package/lib/core/network/accessLogger.js +15 -15
  23. package/lib/core/network/entryPoint.js +12 -12
  24. package/lib/core/network/httpRouter/index.js +4 -4
  25. package/lib/core/network/httpRouter/routePart.js +2 -2
  26. package/lib/core/network/protocols/httpwsProtocol.js +41 -41
  27. package/lib/core/network/protocols/internalProtocol.js +2 -2
  28. package/lib/core/network/protocols/mqttProtocol.js +9 -9
  29. package/lib/core/network/protocols/protocol.js +3 -3
  30. package/lib/core/network/router.js +7 -7
  31. package/lib/core/plugin/plugin.js +23 -23
  32. package/lib/core/plugin/pluginManifest.js +1 -1
  33. package/lib/core/plugin/pluginsManager.js +62 -62
  34. package/lib/core/realtime/notifier.js +14 -14
  35. package/lib/core/security/README.md +223 -0
  36. package/lib/core/security/roleRepository.js +18 -18
  37. package/lib/core/security/securityLoader.js +7 -7
  38. package/lib/core/security/userRepository.js +16 -16
  39. package/lib/core/shared/README.md +3 -0
  40. package/lib/core/shared/abstractManifest.js +1 -1
  41. package/lib/core/shared/sdk/impersonatedSdk.js +1 -1
  42. package/lib/core/shared/store.js +11 -11
  43. package/lib/core/statistics/statistics.js +15 -15
  44. package/lib/core/storage/clientAdapter.js +61 -61
  45. package/lib/core/validation/baseType.js +1 -1
  46. package/lib/core/validation/types/date.js +1 -1
  47. package/lib/core/validation/types/enum.js +5 -5
  48. package/lib/core/validation/types/geoShape.js +13 -13
  49. package/lib/core/validation/types/numeric.js +2 -2
  50. package/lib/core/validation/types/string.js +2 -2
  51. package/lib/core/validation/validation.js +71 -71
  52. package/lib/kerror/codes/index.js +23 -23
  53. package/lib/kuzzle/dumpGenerator.js +17 -17
  54. package/lib/kuzzle/event/kuzzleEventEmitter.js +9 -9
  55. package/lib/kuzzle/event/pipeRunner.js +2 -2
  56. package/lib/kuzzle/internalIndexHandler.js +8 -8
  57. package/lib/kuzzle/log.js +2 -2
  58. package/lib/kuzzle/vault.js +4 -4
  59. package/lib/model/security/role.js +3 -1
  60. package/lib/model/security/user.js +3 -1
  61. package/lib/model/storage/apiKey.js +3 -3
  62. package/lib/model/storage/baseModel.js +7 -7
  63. package/lib/service/cache/redis.js +3 -3
  64. package/lib/service/storage/elasticsearch.js +52 -52
  65. package/lib/service/storage/esWrapper.js +3 -3
  66. package/lib/service/storage/queryTranslator.js +2 -2
  67. package/lib/util/assertType.js +1 -1
  68. package/lib/util/deprecate.js +3 -3
  69. package/lib/util/extractFields.js +2 -2
  70. package/lib/util/wildcard.js +1 -1
  71. package/package.json +68 -81
@@ -31,7 +31,7 @@ class IDCardRenewer {
31
31
  } catch (error) {
32
32
  // eslint-disable-next-line no-console
33
33
  console.error(
34
- `Failed to connect to redis, could not refresh ID card: ${error.message}`
34
+ `Failed to connect to redis, could not refresh ID card: ${error.message}`,
35
35
  );
36
36
  this.parentPort.postMessage({
37
37
  error: `Failed to connect to redis, could not refresh ID card: ${error.message}`,
@@ -47,7 +47,7 @@ class IDCardRenewer {
47
47
  if (!this.disposed) {
48
48
  this.refreshTimer = setInterval(
49
49
  this.renewIDCard.bind(this),
50
- this.refreshDelay
50
+ this.refreshDelay,
51
51
  );
52
52
  }
53
53
 
@@ -69,7 +69,7 @@ class IDCardRenewer {
69
69
  try {
70
70
  const refreshed = await this.redis.commands.pexpire(
71
71
  this.nodeIdKey,
72
- this.refreshDelay * this.refreshMultiplier
72
+ this.refreshDelay * this.refreshMultiplier,
73
73
  );
74
74
  // Unable to refresh the key in time before it expires
75
75
  // => this node is too slow, we need to remove it from the cluster
@@ -108,7 +108,7 @@ class IDCardRenewer {
108
108
  } catch (error) {
109
109
  // eslint-disable-next-line no-console
110
110
  console.error(
111
- `Could not delete key '${this.nodeIdKey}' from redis: ${error.message}`
111
+ `Could not delete key '${this.nodeIdKey}' from redis: ${error.message}`,
112
112
  );
113
113
  }
114
114
  }
@@ -82,7 +82,7 @@ function unstringify(cfg) {
82
82
  .filter(
83
83
  (k) =>
84
84
  !/version$/i.test(k) &&
85
- (typeof cfg[k] === "string" || cfg[k] instanceof Object)
85
+ (typeof cfg[k] === "string" || cfg[k] instanceof Object),
86
86
  )
87
87
  .forEach((k) => {
88
88
  if (typeof cfg[k] === "string") {
@@ -96,7 +96,7 @@ function unstringify(cfg) {
96
96
  } catch (e) {
97
97
  throw kerror.get(
98
98
  "cannot_parse",
99
- `the key "${k}" does not contain a valid stringified JSON (${cfg[k]})`
99
+ `the key "${k}" does not contain a valid stringified JSON (${cfg[k]})`,
100
100
  );
101
101
  }
102
102
  } else if (/^(-|\+)?([0-9]+)$/.test(cfg[k])) {
@@ -160,7 +160,7 @@ function checkLimitsConfig(cfg) {
160
160
  throw kerror.get(
161
161
  "out_of_range",
162
162
  "limits.concurrentRequests",
163
- 'lower than "limits.requestsBufferSize"'
163
+ 'lower than "limits.requestsBufferSize"',
164
164
  );
165
165
  }
166
166
 
@@ -171,7 +171,7 @@ function checkLimitsConfig(cfg) {
171
171
  throw kerror.get(
172
172
  "out_of_range",
173
173
  "limits.requestsBufferWarningThreshold",
174
- "[limits.concurrentRequests, limits.requestsBufferSize]"
174
+ "[limits.concurrentRequests, limits.requestsBufferSize]",
175
175
  );
176
176
  }
177
177
  }
@@ -185,27 +185,27 @@ function checkWebSocketOptions(config) {
185
185
 
186
186
  assert(
187
187
  typeof cfg.enabled === "boolean",
188
- `[websocket] "enabled" parameter: invalid value "${cfg.enabled}" (boolean expected)`
188
+ `[websocket] "enabled" parameter: invalid value "${cfg.enabled}" (boolean expected)`,
189
189
  );
190
190
  assert(
191
191
  Number.isInteger(cfg.idleTimeout) && cfg.idleTimeout >= 0,
192
- `[websocket] "idleTimeout" parameter: invalid value "${cfg.idleTimeout}" (integer >= 1000 expected)`
192
+ `[websocket] "idleTimeout" parameter: invalid value "${cfg.idleTimeout}" (integer >= 1000 expected)`,
193
193
  );
194
194
  assert(
195
195
  Number.isInteger(cfg.rateLimit) && cfg.rateLimit >= 0,
196
- `[websocket] "rateLimit" parameter: invalid value "${cfg.rateLimit}" (integer >= 0 expected)`
196
+ `[websocket] "rateLimit" parameter: invalid value "${cfg.rateLimit}" (integer >= 0 expected)`,
197
197
  );
198
198
  assert(
199
199
  typeof cfg.compression === "boolean",
200
- `[websocket] "compression" parameter: invalid value "${cfg.compression}" (boolean expected)`
200
+ `[websocket] "compression" parameter: invalid value "${cfg.compression}" (boolean expected)`,
201
201
  );
202
202
  assert(
203
203
  typeof cfg.sendPingsAutomatically === "boolean",
204
- `[websocket] "sendPingsAutomatically" parameter: invalid value "${cfg.sendPingsAutomatically}" (boolean expected)`
204
+ `[websocket] "sendPingsAutomatically" parameter: invalid value "${cfg.sendPingsAutomatically}" (boolean expected)`,
205
205
  );
206
206
  assert(
207
207
  typeof cfg.resetIdleTimeoutOnSend === "boolean",
208
- `[websocket] "resetIdleTimeoutOnSend" parameter: invalid value "${cfg.resetIdleTimeoutOnSend}" (boolean expected)`
208
+ `[websocket] "resetIdleTimeoutOnSend" parameter: invalid value "${cfg.resetIdleTimeoutOnSend}" (boolean expected)`,
209
209
  );
210
210
  }
211
211
 
@@ -219,40 +219,40 @@ function checkHttpOptions(config) {
219
219
  assert(
220
220
  typeof config.http.accessControlAllowOrigin === "string" ||
221
221
  Array.isArray(config.http.accessControlAllowOrigin),
222
- `[http] "accessControlAllowOrigin" parameter: invalid value "${config.http.accessControlAllowOrigin}" (array or string expected)`
222
+ `[http] "accessControlAllowOrigin" parameter: invalid value "${config.http.accessControlAllowOrigin}" (array or string expected)`,
223
223
  );
224
224
  assert(
225
225
  typeof config.http.accessControlAllowOriginUseRegExp === "boolean",
226
- `[http] "accessControlAllowOriginUseRegExp" parameter: invalid value "${cfg.accessControlAllowOriginUseRegExp}" (boolean expected)`
226
+ `[http] "accessControlAllowOriginUseRegExp" parameter: invalid value "${cfg.accessControlAllowOriginUseRegExp}" (boolean expected)`,
227
227
  );
228
228
  assert(
229
229
  typeof cfg.enabled === "boolean",
230
- `[http] "enabled" parameter: invalid value "${cfg.enabled}" (boolean expected)`
230
+ `[http] "enabled" parameter: invalid value "${cfg.enabled}" (boolean expected)`,
231
231
  );
232
232
  assert(
233
233
  typeof cfg.allowCompression === "boolean",
234
- `[http] "allowCompression" parameter: invalid value "${cfg.allowCompression}" (boolean expected)`
234
+ `[http] "allowCompression" parameter: invalid value "${cfg.allowCompression}" (boolean expected)`,
235
235
  );
236
236
  assert(
237
237
  Number.isInteger(cfg.maxEncodingLayers) && cfg.maxEncodingLayers >= 1,
238
- `[http] "maxEncodingLayers" parameter: invalid value "${cfg.maxEncodingLayers}" (integer >= 1 expected)`
238
+ `[http] "maxEncodingLayers" parameter: invalid value "${cfg.maxEncodingLayers}" (integer >= 1 expected)`,
239
239
  );
240
240
 
241
241
  const maxFormFileSize = bytes(cfg.maxFormFileSize);
242
242
  assert(
243
243
  Number.isInteger(maxFormFileSize) && maxFormFileSize >= 0,
244
- `[http] "maxFormFileSize" parameter: cannot parse "${cfg.maxFormFileSize}"`
244
+ `[http] "maxFormFileSize" parameter: cannot parse "${cfg.maxFormFileSize}"`,
245
245
  );
246
246
  cfg.maxFormFileSize = maxFormFileSize;
247
247
 
248
248
  assert(
249
249
  typeof config.http.cookieAuthentication === "boolean",
250
- `[http] "cookieAuthentication" parameter: invalid value "${config.http.cookieAuthentication}" (boolean expected)`
250
+ `[http] "cookieAuthentication" parameter: invalid value "${config.http.cookieAuthentication}" (boolean expected)`,
251
251
  );
252
252
  assert(
253
253
  Array.isArray(cfg.additionalContentTypes) &&
254
254
  cfg.additionalContentTypes.every((ct) => typeof ct === "string"),
255
- `[http] "additionalContentTypes" parameter: invalid value "${cfg.additionalContentTypes}" (array of strings expected)`
255
+ `[http] "additionalContentTypes" parameter: invalid value "${cfg.additionalContentTypes}" (array of strings expected)`,
256
256
  );
257
257
  }
258
258
 
@@ -268,25 +268,25 @@ function checkClusterOptions(config) {
268
268
  ]) {
269
269
  assert(
270
270
  typeof cfg[prop] === "number" && cfg[prop] > 0,
271
- `[CONFIG] kuzzlerc.cluster.${prop}: value must be a number greater than 0`
271
+ `[CONFIG] kuzzlerc.cluster.${prop}: value must be a number greater than 0`,
272
272
  );
273
273
  }
274
274
 
275
275
  assert(
276
276
  cfg.syncTimeout < cfg.joinTimeout,
277
- "[CONFIG] kuzzlerc.cluster.syncTimeout: value must be lower than kuzzlerc.cluster.joinTimeout"
277
+ "[CONFIG] kuzzlerc.cluster.syncTimeout: value must be lower than kuzzlerc.cluster.joinTimeout",
278
278
  );
279
279
 
280
280
  for (const prop of ["command", "sync"]) {
281
281
  assert(
282
282
  typeof cfg.ports[prop] === "number" && cfg.ports[prop] > 0,
283
- `[CONFIG] kuzzlerc.cluster.ports.${prop}: value must be a number greater than 0`
283
+ `[CONFIG] kuzzlerc.cluster.ports.${prop}: value must be a number greater than 0`,
284
284
  );
285
285
  }
286
286
 
287
287
  assert(
288
288
  typeof cfg.ipv6 === "boolean",
289
- "[CONFIG] kuzzlerc.cluster.ipv6: boolean expected"
289
+ "[CONFIG] kuzzlerc.cluster.ipv6: boolean expected",
290
290
  );
291
291
  // If config is passed with env variable, ip cannot be the value null
292
292
  // but only blank string or the string "null"
@@ -295,12 +295,12 @@ function checkClusterOptions(config) {
295
295
  }
296
296
  assert(
297
297
  !cfg.ip || ["private", "public"].includes(cfg.ip),
298
- "[CONFIG] kuzzlerc.cluster.ip: invalid value (accepted values: public, private)"
298
+ "[CONFIG] kuzzlerc.cluster.ip: invalid value (accepted values: public, private)",
299
299
  );
300
300
 
301
301
  assert(
302
302
  !cfg.interface || typeof cfg.interface === "string",
303
- "[CONFIG] kuzzlerc.cluster.interface: value must be either null, or a string"
303
+ "[CONFIG] kuzzlerc.cluster.interface: value must be either null, or a string",
304
304
  );
305
305
  }
306
306
 
@@ -63,13 +63,13 @@ class PassportWrapper {
63
63
  "plugin",
64
64
  "runtime",
65
65
  "unexpected_error",
66
- err.message
67
- )
66
+ err.message,
67
+ ),
68
68
  );
69
69
  }
70
70
  } else if (!user) {
71
71
  reject(
72
- kerror.get("plugin", "strategy", "missing_user", info.message)
72
+ kerror.get("plugin", "strategy", "missing_user", info.message),
73
73
  );
74
74
  } else {
75
75
  resolve(user);
@@ -80,7 +80,7 @@ class PassportWrapper {
80
80
  passport.authenticate(
81
81
  strategyName,
82
82
  this.options[strategyName] || {},
83
- authCB
83
+ authCB,
84
84
  )(request, response);
85
85
  } catch (e) {
86
86
  if (e instanceof KuzzleError) {
@@ -92,8 +92,8 @@ class PassportWrapper {
92
92
  "plugin",
93
93
  "runtime",
94
94
  "unexpected_error",
95
- e.message
96
- )
95
+ e.message,
96
+ ),
97
97
  );
98
98
  }
99
99
  }
@@ -53,7 +53,7 @@ class CacheEngine {
53
53
  * @param {string|Array.<string>} keys
54
54
  */
55
55
  global.kuzzle.onAsk("core:cache:internal:del", (keys) =>
56
- this.internal.commands.del(keys)
56
+ this.internal.commands.del(keys),
57
57
  );
58
58
 
59
59
  /**
@@ -62,14 +62,14 @@ class CacheEngine {
62
62
  * @param {number} ttl (in seconds)
63
63
  */
64
64
  global.kuzzle.onAsk("core:cache:internal:expire", (key, ttl) =>
65
- this.internal.commands.expire(key, ttl)
65
+ this.internal.commands.expire(key, ttl),
66
66
  );
67
67
 
68
68
  /**
69
69
  * Wipes the database clean
70
70
  */
71
71
  global.kuzzle.onAsk("core:cache:internal:flushdb", () =>
72
- this.internal.commands.flushdb()
72
+ this.internal.commands.flushdb(),
73
73
  );
74
74
 
75
75
  /**
@@ -77,7 +77,7 @@ class CacheEngine {
77
77
  * @returns {Promise.<Object>}
78
78
  */
79
79
  global.kuzzle.onAsk("core:cache:internal:info:get", () =>
80
- this.internal.info()
80
+ this.internal.info(),
81
81
  );
82
82
 
83
83
  /**
@@ -86,7 +86,7 @@ class CacheEngine {
86
86
  * @return {string}
87
87
  */
88
88
  global.kuzzle.onAsk("core:cache:internal:get", (key) =>
89
- this.internal.commands.get(key)
89
+ this.internal.commands.get(key),
90
90
  );
91
91
 
92
92
  /**
@@ -108,7 +108,7 @@ class CacheEngine {
108
108
  * @param {string} key
109
109
  */
110
110
  global.kuzzle.onAsk("core:cache:internal:persist", (key) =>
111
- this.internal.commands.persist(key)
111
+ this.internal.commands.persist(key),
112
112
  );
113
113
 
114
114
  /**
@@ -117,7 +117,7 @@ class CacheEngine {
117
117
  * @param {number} ttl (in milliseconds)
118
118
  */
119
119
  global.kuzzle.onAsk("core:cache:internal:pexpire", (key, ttl) =>
120
- this.internal.commands.pexpire(key, ttl)
120
+ this.internal.commands.pexpire(key, ttl),
121
121
  );
122
122
 
123
123
  /**
@@ -125,7 +125,7 @@ class CacheEngine {
125
125
  * @param {string} pattern
126
126
  */
127
127
  global.kuzzle.onAsk("core:cache:internal:searchKeys", (pattern) =>
128
- this.internal.searchKeys(pattern)
128
+ this.internal.searchKeys(pattern),
129
129
  );
130
130
 
131
131
  /**
@@ -144,7 +144,7 @@ class CacheEngine {
144
144
  lua: script,
145
145
  numberOfKeys: keys,
146
146
  });
147
- }
147
+ },
148
148
  );
149
149
 
150
150
  /**
@@ -155,7 +155,7 @@ class CacheEngine {
155
155
  * @return {*} script result (if any)
156
156
  */
157
157
  global.kuzzle.onAsk("core:cache:internal:script:execute", (name, ...args) =>
158
- this.internal.client[name](...args)
158
+ this.internal.client[name](...args),
159
159
  );
160
160
 
161
161
  /**
@@ -174,7 +174,7 @@ class CacheEngine {
174
174
  * @returns {Promise.<boolean>} true if the key was set, false otherwise
175
175
  */
176
176
  global.kuzzle.onAsk("core:cache:internal:store", (key, value, opts) =>
177
- this.internal.store(key, value, opts)
177
+ this.internal.store(key, value, opts),
178
178
  );
179
179
 
180
180
  /**
@@ -183,7 +183,7 @@ class CacheEngine {
183
183
  * @param {Array} args -- command arguments
184
184
  */
185
185
  global.kuzzle.onAsk("core:cache:internal:execute", (command, ...args) =>
186
- this.internal.exec(command, ...args)
186
+ this.internal.exec(command, ...args),
187
187
  );
188
188
  }
189
189
 
@@ -193,7 +193,7 @@ class CacheEngine {
193
193
  * @param {string|Array.<string>} keys
194
194
  */
195
195
  global.kuzzle.onAsk("core:cache:public:del", (keys) =>
196
- this.public.commands.del(keys)
196
+ this.public.commands.del(keys),
197
197
  );
198
198
 
199
199
  /**
@@ -202,7 +202,7 @@ class CacheEngine {
202
202
  * @param {Array} args -- command arguments
203
203
  */
204
204
  global.kuzzle.onAsk("core:cache:public:execute", (command, ...args) =>
205
- this.public.exec(command, ...args)
205
+ this.public.exec(command, ...args),
206
206
  );
207
207
 
208
208
  /**
@@ -211,14 +211,14 @@ class CacheEngine {
211
211
  * @param {number} ttl (in seconds)
212
212
  */
213
213
  global.kuzzle.onAsk("core:cache:public:expire", (key, ttl) =>
214
- this.public.commands.expire(key, ttl)
214
+ this.public.commands.expire(key, ttl),
215
215
  );
216
216
 
217
217
  /**
218
218
  * Wipes the database clean
219
219
  */
220
220
  global.kuzzle.onAsk("core:cache:public:flushdb", () =>
221
- this.public.commands.flushdb()
221
+ this.public.commands.flushdb(),
222
222
  );
223
223
 
224
224
  /**
@@ -233,7 +233,7 @@ class CacheEngine {
233
233
  * @return {string}
234
234
  */
235
235
  global.kuzzle.onAsk("core:cache:public:get", (key) =>
236
- this.public.commands.get(key)
236
+ this.public.commands.get(key),
237
237
  );
238
238
 
239
239
  /**
@@ -241,7 +241,7 @@ class CacheEngine {
241
241
  * @param {Array} commands to execute
242
242
  */
243
243
  global.kuzzle.onAsk("core:cache:public:mExecute", (commands) =>
244
- this.public.mExecute(commands)
244
+ this.public.mExecute(commands),
245
245
  );
246
246
 
247
247
  /**
@@ -249,7 +249,7 @@ class CacheEngine {
249
249
  * @param {string} key
250
250
  */
251
251
  global.kuzzle.onAsk("core:cache:public:persist", (key) =>
252
- this.public.commands.persist(key)
252
+ this.public.commands.persist(key),
253
253
  );
254
254
 
255
255
  /**
@@ -268,7 +268,7 @@ class CacheEngine {
268
268
  * @returns {Promise.<boolean>} true if the key was set, false otherwise
269
269
  */
270
270
  global.kuzzle.onAsk("core:cache:public:store", (key, value, opts) =>
271
- this.public.store(key, value, opts)
271
+ this.public.store(key, value, opts),
272
272
  );
273
273
  }
274
274
  }
@@ -51,7 +51,7 @@ class AccessLogger {
51
51
  for (const out of config.logs.transports) {
52
52
  if (out.transport && !ALLOWED_TRANSPORTS.includes(out.transport)) {
53
53
  global.kuzzle.log.error(
54
- `Failed to initialize logger transport "${out.transport}": unsupported transport. Skipped.`
54
+ `Failed to initialize logger transport "${out.transport}": unsupported transport. Skipped.`,
55
55
  );
56
56
  } else {
57
57
  this.isActive = this.isActive || !out.silent;
@@ -63,7 +63,7 @@ class AccessLogger {
63
63
  }
64
64
 
65
65
  const anonymous = await global.kuzzle.ask(
66
- "core:security:user:anonymous:get"
66
+ "core:security:user:anonymous:get",
67
67
  );
68
68
 
69
69
  this.worker = new Worker(__filename, {
@@ -103,7 +103,7 @@ class AccessLogger {
103
103
  });
104
104
  } catch (error) {
105
105
  global.kuzzle.log.error(
106
- `Failed to write access log for request "${request.id}": ${error.message}`
106
+ `Failed to write access log for request "${request.id}": ${error.message}`,
107
107
  );
108
108
  }
109
109
  }
@@ -124,7 +124,7 @@ class AccessLoggerWorker {
124
124
  connection,
125
125
  new KuzzleRequest(request.data, request.options),
126
126
  size,
127
- extra
127
+ extra,
128
128
  );
129
129
  });
130
130
  }
@@ -154,8 +154,8 @@ class AccessLoggerWorker {
154
154
  humanReadableUnhandledException:
155
155
  conf.humanReadableUnhandledException || true,
156
156
  stderrLevels: conf.stderrLevels || ["error", "debug"],
157
- })
158
- )
157
+ }),
158
+ ),
159
159
  );
160
160
  break;
161
161
  case "elasticsearch":
@@ -171,8 +171,8 @@ class AccessLoggerWorker {
171
171
  mappingTemplate:
172
172
  conf.mappingTemplate || "access.log.mapping.json",
173
173
  messageType: conf.messageType || "access",
174
- })
175
- )
174
+ }),
175
+ ),
176
176
  );
177
177
  break;
178
178
  case "file":
@@ -187,8 +187,8 @@ class AccessLoggerWorker {
187
187
  maxSize: conf.maxSize,
188
188
  tailable: conf.tailable,
189
189
  zippedArchive: conf.zippedArchive || false,
190
- })
191
- )
190
+ }),
191
+ ),
192
192
  );
193
193
  break;
194
194
  case "syslog":
@@ -205,8 +205,8 @@ class AccessLoggerWorker {
205
205
  port: conf.port || 514,
206
206
  protocol: conf.protocol || "udp4",
207
207
  type: conf.type || "BSD",
208
- })
209
- )
208
+ }),
209
+ ),
210
210
  );
211
211
  break;
212
212
  default:
@@ -312,7 +312,7 @@ class AccessLoggerWorker {
312
312
  : "-";
313
313
 
314
314
  this.logger.info(
315
- `${ip} - ${user} [${when}] "${verb} ${url} ${protocol}" ${status} ${size} ${referer} ${agent}`
315
+ `${ip} - ${user} [${when}] "${verb} ${url} ${protocol}" ${status} ${size} ${referer} ${agent}`,
316
316
  );
317
317
  }
318
318
 
@@ -328,7 +328,7 @@ class AccessLoggerWorker {
328
328
 
329
329
  const idx = Math.max(
330
330
  0,
331
- ips.length - 1 - this.config.logs.accessLogIpOffset
331
+ ips.length - 1 - this.config.logs.accessLogIpOffset,
332
332
  );
333
333
 
334
334
  return ips[idx];
@@ -341,7 +341,7 @@ if (!isMainThread) {
341
341
 
342
342
  const worker = new AccessLoggerWorker(
343
343
  workerData.config,
344
- workerData.anonymousUserId
344
+ workerData.anonymousUserId,
345
345
  );
346
346
 
347
347
  worker.init();
@@ -114,7 +114,7 @@ class EntryPoint {
114
114
  if (!enabled) {
115
115
  this.protocols.delete(protocol.name);
116
116
  }
117
- })
117
+ }),
118
118
  );
119
119
  }
120
120
 
@@ -143,7 +143,7 @@ class EntryPoint {
143
143
  this.protocols.get(client.protocol).joinChannel(channel, connectionId);
144
144
  } catch (e) {
145
145
  global.kuzzle.log.error(
146
- `[join] protocol ${client && client.protocol} failed: ${e.message}`
146
+ `[join] protocol ${client && client.protocol} failed: ${e.message}`,
147
147
  );
148
148
  }
149
149
  }
@@ -152,7 +152,7 @@ class EntryPoint {
152
152
  debug(
153
153
  '[server] connection "%s" leaving channel "%s"',
154
154
  connectionId,
155
- channel
155
+ channel,
156
156
  );
157
157
 
158
158
  const client = this._clients.get(connectionId);
@@ -167,7 +167,7 @@ class EntryPoint {
167
167
  global.kuzzle.log.error(
168
168
  `[leave channel] protocol ${client && client.protocol} failed: ${
169
169
  e.message
170
- }`
170
+ }`,
171
171
  );
172
172
  }
173
173
  }
@@ -203,13 +203,13 @@ class EntryPoint {
203
203
  .then(() => protocol.init(this, new Context()))
204
204
  .catch((error) => {
205
205
  global.kuzzle.log.error(
206
- `Error during "${manifest.name}" protocol init:`
206
+ `Error during "${manifest.name}" protocol init:`,
207
207
  );
208
208
  throw error;
209
209
  })
210
210
  .timeout(
211
211
  initTimeout,
212
- `Protocol "${manifest.name}" initialization timed out after ${initTimeout}ms. Try to increase the configuration "services.common.defaultInitTimeout".`
212
+ `Protocol "${manifest.name}" initialization timed out after ${initTimeout}ms. Try to increase the configuration "services.common.defaultInitTimeout".`,
213
213
  )
214
214
  .then(() => {
215
215
  if (this.protocols.has(manifest.name)) {
@@ -217,7 +217,7 @@ class EntryPoint {
217
217
  "protocol",
218
218
  "runtime",
219
219
  "already_exists",
220
- manifest.name
220
+ manifest.name,
221
221
  );
222
222
  }
223
223
 
@@ -282,7 +282,7 @@ class EntryPoint {
282
282
  debug(
283
283
  "New connection created: %s (protocol: %s)",
284
284
  connection.id,
285
- connection.protocol
285
+ connection.protocol,
286
286
  );
287
287
  }
288
288
 
@@ -302,7 +302,7 @@ class EntryPoint {
302
302
  debug(
303
303
  "Removed connection: %s (protocol: %s)",
304
304
  connection.id,
305
- connection.protocol
305
+ connection.protocol,
306
306
  );
307
307
  }
308
308
  }
@@ -319,7 +319,7 @@ class EntryPoint {
319
319
  protocol.broadcast(sanitized);
320
320
  } catch (e) {
321
321
  global.kuzzle.log.error(
322
- `[broadcast] protocol ${name} failed: ${e.message}\n${e.stack}`
322
+ `[broadcast] protocol ${name} failed: ${e.message}\n${e.stack}`,
323
323
  );
324
324
  }
325
325
  }
@@ -336,7 +336,7 @@ class EntryPoint {
336
336
  debug(
337
337
  '[server] sending notification to client with connection id "%s": %a',
338
338
  data.connectionId,
339
- data
339
+ data,
340
340
  );
341
341
 
342
342
  const client = this._clients.get(data.connectionId);
@@ -349,7 +349,7 @@ class EntryPoint {
349
349
  this.protocols.get(client.protocol).notify(removeStacktrace(data));
350
350
  } catch (e) {
351
351
  global.kuzzle.log.error(
352
- `[notify] protocol ${client.protocol} failed: ${e.message}`
352
+ `[notify] protocol ${client.protocol} failed: ${e.message}`,
353
353
  );
354
354
  }
355
355
  }
@@ -75,7 +75,7 @@ class Router {
75
75
  request.setResult({}, 200);
76
76
  cb(request);
77
77
  },
78
- this.routes.HEAD
78
+ this.routes.HEAD,
79
79
  );
80
80
  }
81
81
 
@@ -197,11 +197,11 @@ class Router {
197
197
  */
198
198
  routeUnhandledHttpMethod(message, cb) {
199
199
  const requestContext = global.kuzzle.router.connections.get(
200
- message.connection.id
200
+ message.connection.id,
201
201
  ),
202
202
  request = new Request(
203
203
  { requestId: message.requestId },
204
- requestContext && requestContext.toJSON()
204
+ requestContext && requestContext.toJSON(),
205
205
  );
206
206
 
207
207
  // Set Headers if not present
@@ -241,7 +241,7 @@ function applyACAOHeader(message, request) {
241
241
  "Access-Control-Allow-Origin": message.headers.origin,
242
242
  Vary: "Origin",
243
243
  },
244
- true
244
+ true,
245
245
  );
246
246
  }
247
247
  }
@@ -124,7 +124,7 @@ function getHandlerPart(routePart, parts, routeHandler, placeholders = []) {
124
124
  routePart.subparts[part],
125
125
  parts,
126
126
  routeHandler,
127
- placeholders
127
+ placeholders,
128
128
  );
129
129
  }
130
130
 
@@ -134,7 +134,7 @@ function getHandlerPart(routePart, parts, routeHandler, placeholders = []) {
134
134
  routePart.subparts["*"],
135
135
  parts,
136
136
  routeHandler,
137
- placeholders
137
+ placeholders,
138
138
  );
139
139
  }
140
140