@pbvision/fastify-firestore-service 0.0.31 → 0.0.33

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pbvision/fastify-firestore-service",
3
- "version": "0.0.31",
3
+ "version": "0.0.33",
4
4
  "description": "Web Framework using Fastify and Firestore ORM",
5
5
  "license": "Apache-2.0",
6
6
  "type": "module",
@@ -1,5 +1,4 @@
1
1
  import querystring from 'node:querystring'
2
- import zlib from 'node:zlib'
3
2
 
4
3
  import realFetch from 'node-fetch'
5
4
 
@@ -8,16 +7,10 @@ async function fetchWrapper (request, mockedFetch) {
8
7
  let { body, headers } = request
9
8
  headers = { ...headers } // copy the headers before we change them
10
9
 
11
- // compress the body using brotli
12
10
  if (json) {
13
11
  headers['content-type'] = 'application/json'
14
12
  body = JSON.stringify(request.json)
15
13
  }
16
- if (body && compress) {
17
- body = zlib.brotliCompressSync(body)
18
- headers['content-encoding'] = 'br'
19
- }
20
-
21
14
  const fetch = (mockedFetch === false)
22
15
  ? realFetch
23
16
  : (mockedFetch ?? fetchWrapper.__mock ?? realFetch)
@@ -30,7 +23,7 @@ async function fetchWrapper (request, mockedFetch) {
30
23
  fullURL += `?${qsStr}`
31
24
  }
32
25
  }
33
- const options = { body, headers, method, compress: false }
26
+ const options = { body, headers, method, compress }
34
27
  return fetch(fullURL, options)
35
28
  }
36
29
 
@@ -2,7 +2,7 @@ import S from '@pbvision/schema'
2
2
  import * as Sentry from '@sentry/node'
3
3
  import fp from 'fastify-plugin'
4
4
 
5
- import { InvalidInputException } from '../api/exception.js'
5
+ import { InvalidInputException, __RequestDone } from '../api/exception.js'
6
6
 
7
7
  export default fp(function (fastify, options, next) {
8
8
  const isLocalhost = process.env.NODE_ENV === 'localhost'
@@ -112,11 +112,15 @@ export default fp(function (fastify, options, next) {
112
112
  url: req.url,
113
113
  status: errInfo.status
114
114
  })
115
- scope.setExtras({
115
+ const extras = {
116
116
  msg: errInfo.message,
117
117
  reqId: req.id,
118
118
  userAgent: req.headers['user-agent'] ?? 'not set'
119
- })
119
+ }
120
+ if (error instanceof __RequestDone) {
121
+ extras.data = error.data
122
+ }
123
+ scope.setExtras(extras)
120
124
  Sentry.captureException(error)
121
125
  })
122
126
 
package/test/base-test.js CHANGED
@@ -152,10 +152,6 @@ function mockNodeFetch () {
152
152
  }
153
153
  delete request.headers['content-encoding']
154
154
  const body = options.body
155
- ? (request.compress
156
- ? zlib.brotliDecompressSync(options.body)
157
- : options.body)
158
- : options.body
159
155
  if (options.headers['content-type'] === 'application/json') {
160
156
  delete options.headers['content-type']
161
157
  request.json = JSON.parse(body)