@naturalcycles/backend-lib 9.40.0 → 9.42.0
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.
|
@@ -9,6 +9,7 @@ export interface DeployHealthCheckOptions {
|
|
|
9
9
|
gaeProject?: string;
|
|
10
10
|
gaeService?: string;
|
|
11
11
|
gaeVersion?: string;
|
|
12
|
+
authHeader?: string;
|
|
12
13
|
}
|
|
13
14
|
export declare const deployHealthCheckYargsOptions: {
|
|
14
15
|
readonly thresholdHealthy: {
|
|
@@ -50,6 +51,9 @@ export declare const deployHealthCheckYargsOptions: {
|
|
|
50
51
|
readonly gaeVersion: {
|
|
51
52
|
readonly type: "string";
|
|
52
53
|
};
|
|
54
|
+
readonly authHeader: {
|
|
55
|
+
readonly type: "string";
|
|
56
|
+
};
|
|
53
57
|
};
|
|
54
58
|
/**
|
|
55
59
|
* Requires up to `healthyThreshold` consecutive OK responses to succeed.
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { inspect } from 'node:util';
|
|
2
2
|
import { _ms, _since } from '@naturalcycles/js-lib/datetime';
|
|
3
3
|
import { getFetcher } from '@naturalcycles/js-lib/http';
|
|
4
|
-
import { _filterFalsyValues } from '@naturalcycles/js-lib/object/object.util.js';
|
|
4
|
+
import { _filterFalsyValues, _filterUndefinedValues, } from '@naturalcycles/js-lib/object/object.util.js';
|
|
5
5
|
import { pDelay } from '@naturalcycles/js-lib/promise/pDelay.js';
|
|
6
6
|
import { dimGrey, red } from '@naturalcycles/nodejs-lib/colors';
|
|
7
7
|
import { exec2 } from '@naturalcycles/nodejs-lib/exec2';
|
|
@@ -46,6 +46,9 @@ export const deployHealthCheckYargsOptions = {
|
|
|
46
46
|
gaeVersion: {
|
|
47
47
|
type: 'string',
|
|
48
48
|
},
|
|
49
|
+
authHeader: {
|
|
50
|
+
type: 'string',
|
|
51
|
+
},
|
|
49
52
|
};
|
|
50
53
|
const inspectOpt = {
|
|
51
54
|
colors: true,
|
|
@@ -57,7 +60,7 @@ const inspectOpt = {
|
|
|
57
60
|
* Fails after maxTries.
|
|
58
61
|
*/
|
|
59
62
|
export async function deployHealthCheck(url, opt = {}) {
|
|
60
|
-
const { thresholdHealthy = 5, thresholdUnhealthy = 8, maxTries = 30, timeoutSec = 30, intervalSec = 1, logOnFailure, logOnSuccess, gaeProject, gaeService, gaeVersion, } = opt;
|
|
63
|
+
const { thresholdHealthy = 5, thresholdUnhealthy = 8, maxTries = 30, timeoutSec = 30, intervalSec = 1, logOnFailure, logOnSuccess, gaeProject, gaeService, gaeVersion, authHeader, } = opt;
|
|
61
64
|
let attempt = 0;
|
|
62
65
|
let countHealthy = 0;
|
|
63
66
|
let countUnhealthy = 0;
|
|
@@ -89,7 +92,7 @@ export async function deployHealthCheck(url, opt = {}) {
|
|
|
89
92
|
attempt++;
|
|
90
93
|
console.log([`>>`, dimGrey(url), inspect({ attempt }, inspectOpt)].join(' '));
|
|
91
94
|
const started = Date.now();
|
|
92
|
-
const { err, statusCode = 0 } = await fetcher.doFetch({
|
|
95
|
+
const { err, statusCode = 0 } = await fetcher.doFetch(_filterUndefinedValues({
|
|
93
96
|
url,
|
|
94
97
|
responseType: 'json',
|
|
95
98
|
timeoutSeconds: timeoutSec,
|
|
@@ -97,7 +100,10 @@ export async function deployHealthCheck(url, opt = {}) {
|
|
|
97
100
|
count: 0,
|
|
98
101
|
},
|
|
99
102
|
redirect: 'error',
|
|
100
|
-
|
|
103
|
+
headers: {
|
|
104
|
+
Authorization: authHeader,
|
|
105
|
+
},
|
|
106
|
+
}));
|
|
101
107
|
if (err) {
|
|
102
108
|
console.log(err);
|
|
103
109
|
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@naturalcycles/backend-lib",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "9.
|
|
4
|
+
"version": "9.42.0",
|
|
5
5
|
"peerDependencies": {
|
|
6
6
|
"@sentry/node": "^10"
|
|
7
7
|
},
|
|
@@ -72,7 +72,7 @@
|
|
|
72
72
|
"directory": "packages/backend-lib"
|
|
73
73
|
},
|
|
74
74
|
"engines": {
|
|
75
|
-
"node": ">=
|
|
75
|
+
"node": ">=24.10.0"
|
|
76
76
|
},
|
|
77
77
|
"description": "Standard library for making Express.js / AppEngine based backend services",
|
|
78
78
|
"author": "Natural Cycles Team",
|
package/readme.md
CHANGED
|
@@ -9,10 +9,3 @@
|
|
|
9
9
|
[](https://github.com/NaturalCycles/backend-lib/actions)
|
|
10
10
|
|
|
11
11
|
# [Documentation](https://naturalcycles.github.io/backend-lib/)
|
|
12
|
-
|
|
13
|
-
# Packaging
|
|
14
|
-
|
|
15
|
-
- `engines.node`: latest Node.js LTS
|
|
16
|
-
- `main: dist/index.js`: commonjs, es2020
|
|
17
|
-
- `types: dist/index.d.ts`: typescript types
|
|
18
|
-
- `/src` folder with source `*.ts` files included
|
|
@@ -2,7 +2,10 @@ import type { InspectOptions } from 'node:util'
|
|
|
2
2
|
import { inspect } from 'node:util'
|
|
3
3
|
import { _ms, _since } from '@naturalcycles/js-lib/datetime'
|
|
4
4
|
import { getFetcher } from '@naturalcycles/js-lib/http'
|
|
5
|
-
import {
|
|
5
|
+
import {
|
|
6
|
+
_filterFalsyValues,
|
|
7
|
+
_filterUndefinedValues,
|
|
8
|
+
} from '@naturalcycles/js-lib/object/object.util.js'
|
|
6
9
|
import { pDelay } from '@naturalcycles/js-lib/promise/pDelay.js'
|
|
7
10
|
import type { UnixTimestampMillis } from '@naturalcycles/js-lib/types'
|
|
8
11
|
import { dimGrey, red } from '@naturalcycles/nodejs-lib/colors'
|
|
@@ -20,6 +23,7 @@ export interface DeployHealthCheckOptions {
|
|
|
20
23
|
gaeProject?: string
|
|
21
24
|
gaeService?: string
|
|
22
25
|
gaeVersion?: string
|
|
26
|
+
authHeader?: string
|
|
23
27
|
}
|
|
24
28
|
|
|
25
29
|
export const deployHealthCheckYargsOptions = {
|
|
@@ -62,6 +66,9 @@ export const deployHealthCheckYargsOptions = {
|
|
|
62
66
|
gaeVersion: {
|
|
63
67
|
type: 'string',
|
|
64
68
|
},
|
|
69
|
+
authHeader: {
|
|
70
|
+
type: 'string',
|
|
71
|
+
},
|
|
65
72
|
} as const
|
|
66
73
|
|
|
67
74
|
const inspectOpt: InspectOptions = {
|
|
@@ -89,6 +96,7 @@ export async function deployHealthCheck(
|
|
|
89
96
|
gaeProject,
|
|
90
97
|
gaeService,
|
|
91
98
|
gaeVersion,
|
|
99
|
+
authHeader,
|
|
92
100
|
} = opt
|
|
93
101
|
|
|
94
102
|
let attempt = 0
|
|
@@ -134,15 +142,20 @@ export async function deployHealthCheck(
|
|
|
134
142
|
|
|
135
143
|
const started = Date.now() as UnixTimestampMillis
|
|
136
144
|
|
|
137
|
-
const { err, statusCode = 0 } = await fetcher.doFetch(
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
145
|
+
const { err, statusCode = 0 } = await fetcher.doFetch(
|
|
146
|
+
_filterUndefinedValues({
|
|
147
|
+
url,
|
|
148
|
+
responseType: 'json',
|
|
149
|
+
timeoutSeconds: timeoutSec,
|
|
150
|
+
retry: {
|
|
151
|
+
count: 0,
|
|
152
|
+
},
|
|
153
|
+
redirect: 'error',
|
|
154
|
+
headers: {
|
|
155
|
+
Authorization: authHeader,
|
|
156
|
+
},
|
|
157
|
+
}),
|
|
158
|
+
)
|
|
146
159
|
|
|
147
160
|
if (err) {
|
|
148
161
|
console.log(err)
|