@pbvision/fastify-firestore-service 0.0.41 → 0.0.43
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/package.json +1 -1
- package/src/api/api.js +25 -8
package/package.json
CHANGED
package/src/api/api.js
CHANGED
|
@@ -258,9 +258,13 @@ class API {
|
|
|
258
258
|
* @private
|
|
259
259
|
*/
|
|
260
260
|
__setCORSHeaders (origin, headers) {
|
|
261
|
-
this.
|
|
261
|
+
this.constructor.setCORSHeadersOnReply(this.__reply, origin, headers)
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
static setCORSHeadersOnReply (reply, origin, headers) {
|
|
265
|
+
reply.header('Access-Control-Allow-Origin', origin)
|
|
262
266
|
if (headers && headers.length) {
|
|
263
|
-
|
|
267
|
+
reply.header('Access-Control-Allow-Headers', headers.join(', '))
|
|
264
268
|
}
|
|
265
269
|
}
|
|
266
270
|
|
|
@@ -413,7 +417,7 @@ class API {
|
|
|
413
417
|
* used if these fields don't include sensitive information.
|
|
414
418
|
*/
|
|
415
419
|
__trackInputsWithSentry () {
|
|
416
|
-
const inputs = this.getInputsToTrackWithSentry()
|
|
420
|
+
const inputs = this.constructor.getInputsToTrackWithSentry(this.req)
|
|
417
421
|
// istanbul ignore else
|
|
418
422
|
if (inputs) {
|
|
419
423
|
this.setSentryContext('inputs', inputs)
|
|
@@ -427,11 +431,11 @@ class API {
|
|
|
427
431
|
* helpful debugging information but should only be
|
|
428
432
|
* used if these fields don't include sensitive information.
|
|
429
433
|
*/
|
|
430
|
-
getInputsToTrackWithSentry () {
|
|
434
|
+
static getInputsToTrackWithSentry (req) {
|
|
431
435
|
return {
|
|
432
|
-
...
|
|
433
|
-
...
|
|
434
|
-
...
|
|
436
|
+
...req.query,
|
|
437
|
+
...req.params,
|
|
438
|
+
...req.body
|
|
435
439
|
}
|
|
436
440
|
}
|
|
437
441
|
|
|
@@ -797,7 +801,20 @@ class API {
|
|
|
797
801
|
let ret
|
|
798
802
|
try {
|
|
799
803
|
if (req.validationError) {
|
|
800
|
-
req.__sentry = { context: {
|
|
804
|
+
req.__sentry = { context: {} }
|
|
805
|
+
const errCopy = { ...req.validationError }
|
|
806
|
+
errCopy.validation = JSON.stringify(errCopy.validation, null, 4)
|
|
807
|
+
req.__sentry.context.validationError = errCopy
|
|
808
|
+
try {
|
|
809
|
+
req.__sentry.context.inputs = this.getInputsToTrackWithSentry(req)
|
|
810
|
+
} catch (err) {
|
|
811
|
+
// istanbul ignore next
|
|
812
|
+
console.warn('trying to get inputs to track failed', err)
|
|
813
|
+
}
|
|
814
|
+
if (this.CORS_ORIGIN) {
|
|
815
|
+
this.setCORSHeadersOnReply(
|
|
816
|
+
reply, this.getCORSOrigin(), this.CORS_HEADERS)
|
|
817
|
+
}
|
|
801
818
|
throw new InvalidInputException(req.validationError)
|
|
802
819
|
}
|
|
803
820
|
ret = await this._callAndHandleRequestDone(reply, async () => {
|