@naturalcycles/backend-lib 4.17.3 → 4.17.5

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.
@@ -67,7 +67,6 @@ async function deployHealthCheck(url, opt = {}) {
67
67
  let currentInterval = intervalSec * 1000;
68
68
  const fetcher = (0, js_lib_1.getFetcher)();
69
69
  while (!done) {
70
- // eslint-disable-next-line no-await-in-loop
71
70
  await makeAttempt();
72
71
  }
73
72
  if (failed) {
@@ -84,7 +83,8 @@ async function deployHealthCheck(url, opt = {}) {
84
83
  attempt++;
85
84
  console.log([`>>`, (0, colors_1.dimGrey)(url), (0, node_util_1.inspect)({ attempt }, inspectOpt)].join(' '));
86
85
  const started = Date.now();
87
- const { err, fetchResponse } = await fetcher.doFetch(url, {
86
+ const { err, fetchResponse } = await fetcher.doFetch({
87
+ url,
88
88
  mode: 'json',
89
89
  timeoutSeconds: timeoutSec,
90
90
  retry: {
@@ -5,7 +5,6 @@ exports.catchWrapper = void 0;
5
5
  // https://stackoverflow.com/a/43564267/4919972
6
6
  const catchWrapper = (fn) => async (req, res, next) => {
7
7
  try {
8
- // eslint-disable-next-line @typescript-eslint/await-thenable
9
8
  await fn(req, res, next);
10
9
  }
11
10
  catch (err) {
@@ -53,6 +53,9 @@ function respondWithError(req, res, err) {
53
53
  delete httpError.stack;
54
54
  httpError.data.errorId = errorId;
55
55
  httpError.data.backendResponseStatusCode ||= 500; // default to 500
56
+ // httpStatusCode is for backwards-compatibility
57
+ // Otherwise, it breaks the _isHttpErrorResponse function check, and error get formatted/detected wrongly
58
+ httpError.data['httpStatusCode'] = httpError.data.backendResponseStatusCode;
56
59
  httpError.data.headersSent = headersSent || undefined;
57
60
  httpError.data.report ||= undefined; // set to undefined if false
58
61
  (0, js_lib_1._filterUndefinedValues)(httpError.data, true);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@naturalcycles/backend-lib",
3
- "version": "4.17.3",
3
+ "version": "4.17.5",
4
4
  "scripts": {
5
5
  "prepare": "husky install && patch-package",
6
6
  "serve": "APP_ENV=dev nodemon",
@@ -97,7 +97,6 @@ export async function deployHealthCheck(
97
97
  const fetcher = getFetcher()
98
98
 
99
99
  while (!done) {
100
- // eslint-disable-next-line no-await-in-loop
101
100
  await makeAttempt()
102
101
  }
103
102
 
@@ -126,7 +125,8 @@ export async function deployHealthCheck(
126
125
 
127
126
  const started = Date.now()
128
127
 
129
- const { err, fetchResponse } = await fetcher.doFetch(url, {
128
+ const { err, fetchResponse } = await fetcher.doFetch({
129
+ url,
130
130
  mode: 'json',
131
131
  timeoutSeconds: timeoutSec,
132
132
  retry: {
@@ -6,7 +6,6 @@ export const catchWrapper =
6
6
  (fn: BackendRequestHandler): BackendRequestHandler =>
7
7
  async (req, res, next) => {
8
8
  try {
9
- // eslint-disable-next-line @typescript-eslint/await-thenable
10
9
  await fn(req, res, next)
11
10
  } catch (err) {
12
11
  next(err)
@@ -86,6 +86,9 @@ export function respondWithError(req: BackendRequest, res: BackendResponse, err:
86
86
 
87
87
  httpError.data.errorId = errorId
88
88
  httpError.data.backendResponseStatusCode ||= 500 // default to 500
89
+ // httpStatusCode is for backwards-compatibility
90
+ // Otherwise, it breaks the _isHttpErrorResponse function check, and error get formatted/detected wrongly
91
+ httpError.data['httpStatusCode'] = httpError.data.backendResponseStatusCode
89
92
  httpError.data.headersSent = headersSent || undefined
90
93
  httpError.data.report ||= undefined // set to undefined if false
91
94
  _filterUndefinedValues(httpError.data, true)