@pbvision/fastify-firestore-service 0.0.26 → 0.0.28
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 +2 -2
- package/src/api/api.js +13 -11
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pbvision/fastify-firestore-service",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.28",
|
|
4
4
|
"description": "Web Framework using Fastify and Firestore ORM",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"type": "module",
|
|
@@ -42,7 +42,7 @@
|
|
|
42
42
|
"@fastify/static": "^6.12",
|
|
43
43
|
"@fastify/swagger": "^8.1.0",
|
|
44
44
|
"@fastify/swagger-ui": "^2.0.1",
|
|
45
|
-
"@pbvision/firestore-orm": "^0.0.
|
|
45
|
+
"@pbvision/firestore-orm": "^0.0.12",
|
|
46
46
|
"@sentry/node": "^7.91.0",
|
|
47
47
|
"fastify": "^4.10.0",
|
|
48
48
|
"fastify-plugin": "^4.5.1",
|
package/src/api/api.js
CHANGED
|
@@ -341,7 +341,7 @@ class API {
|
|
|
341
341
|
* @protected
|
|
342
342
|
*/
|
|
343
343
|
async callAPI ({
|
|
344
|
-
method = 'POST', headers = {}, url, body, qsParams
|
|
344
|
+
method = 'POST', headers = {}, url, body, qsParams, ignoreRespBody = false
|
|
345
345
|
}) {
|
|
346
346
|
headers = {
|
|
347
347
|
...headers,
|
|
@@ -366,17 +366,19 @@ class API {
|
|
|
366
366
|
code: resp.status,
|
|
367
367
|
isOk: resp.status >= 200 && resp.status <= 299
|
|
368
368
|
}
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
if (
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
369
|
+
if (!ignoreRespBody) {
|
|
370
|
+
const respBody = await resp.text()
|
|
371
|
+
if (respBody) {
|
|
372
|
+
if (resp.headers.get('content-type')?.startsWith('application/json')) {
|
|
373
|
+
try {
|
|
374
|
+
ret.data = JSON.parse(respBody)
|
|
375
|
+
} catch (e) {
|
|
376
|
+
// istanbul ignore next
|
|
377
|
+
throw new Error(`JSON.parse failed on ${respBody} with reason ${e}.`)
|
|
378
|
+
}
|
|
379
|
+
} else {
|
|
380
|
+
ret.data = respBody
|
|
377
381
|
}
|
|
378
|
-
} else {
|
|
379
|
-
ret.data = respBody
|
|
380
382
|
}
|
|
381
383
|
}
|
|
382
384
|
return ret
|