@naturalcycles/backend-lib 9.32.0 → 9.33.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.
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import type { NonNegativeInteger, NumberOfMilliseconds, NumberOfSeconds, PositiveInteger, UnixTimestamp } from '@naturalcycles/js-lib/types';
|
|
2
|
-
export interface
|
|
1
|
+
import type { AnyObject, NonNegativeInteger, NumberOfMilliseconds, NumberOfSeconds, PositiveInteger, UnixTimestamp } from '@naturalcycles/js-lib/types';
|
|
2
|
+
export interface CloudRunConfig {
|
|
3
3
|
gcpProject: string;
|
|
4
4
|
/**
|
|
5
5
|
* Name of the Cloud Run service.
|
|
6
6
|
*/
|
|
7
7
|
cloudRunService: string;
|
|
8
|
-
cloudRunServiceBase
|
|
8
|
+
cloudRunServiceBase?: string;
|
|
9
9
|
runtimeServiceAccount: string;
|
|
10
10
|
/**
|
|
11
11
|
* GCP region where the Cloud Run service is deployed. Example: 'europe-west1'
|
|
@@ -62,10 +62,6 @@ export interface CloudRunStartupProbeConfig {
|
|
|
62
62
|
timeoutSeconds: NumberOfSeconds;
|
|
63
63
|
periodSeconds: NumberOfSeconds;
|
|
64
64
|
}
|
|
65
|
-
/**
|
|
66
|
-
* Experimental, subject to change.
|
|
67
|
-
*/
|
|
68
|
-
export declare const defaultStartupProbeConfig: CloudRunStartupProbeConfig;
|
|
69
65
|
export interface CloudRunEnv {
|
|
70
66
|
APP_ENV: string;
|
|
71
67
|
/**
|
|
@@ -101,3 +97,16 @@ export interface CloudRunEnv {
|
|
|
101
97
|
OTEL_EXPORTER_OTLP_ENDPOINT?: string;
|
|
102
98
|
OTEL_LOG_LEVEL?: 'INFO' | 'DEBUG';
|
|
103
99
|
}
|
|
100
|
+
/**
|
|
101
|
+
* @experimental
|
|
102
|
+
*/
|
|
103
|
+
declare class CloudRunService {
|
|
104
|
+
/**
|
|
105
|
+
* Turns an object into a string representation where each
|
|
106
|
+
* key-value pair is represented as `key1=value1,key2=value2,...`.
|
|
107
|
+
*/
|
|
108
|
+
stringifyObject(obj: AnyObject): string;
|
|
109
|
+
readonly defaultStartupProbeConfig: CloudRunStartupProbeConfig;
|
|
110
|
+
}
|
|
111
|
+
export declare const cloudRunService: CloudRunService;
|
|
112
|
+
export {};
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { _filterUndefinedValues } from '@naturalcycles/js-lib/object';
|
|
2
|
+
/**
|
|
3
|
+
* @experimental
|
|
4
|
+
*/
|
|
5
|
+
class CloudRunService {
|
|
6
|
+
/**
|
|
7
|
+
* Turns an object into a string representation where each
|
|
8
|
+
* key-value pair is represented as `key1=value1,key2=value2,...`.
|
|
9
|
+
*/
|
|
10
|
+
stringifyObject(obj) {
|
|
11
|
+
const filteredObj = _filterUndefinedValues(obj);
|
|
12
|
+
return Object.entries(filteredObj)
|
|
13
|
+
.map(([key, value]) => `${key}=${value}`)
|
|
14
|
+
.join(',');
|
|
15
|
+
}
|
|
16
|
+
defaultStartupProbeConfig = {
|
|
17
|
+
'httpGet.path': '/',
|
|
18
|
+
'httpGet.port': 8080,
|
|
19
|
+
initialDelaySeconds: 3,
|
|
20
|
+
failureThreshold: 50,
|
|
21
|
+
timeoutSeconds: 1,
|
|
22
|
+
periodSeconds: 2,
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
export const cloudRunService = new CloudRunService();
|
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.33.0",
|
|
5
5
|
"peerDependencies": {
|
|
6
6
|
"@sentry/node": "^10"
|
|
7
7
|
},
|
|
@@ -29,7 +29,7 @@
|
|
|
29
29
|
"@sentry/node": "^10",
|
|
30
30
|
"@types/ejs": "^3",
|
|
31
31
|
"fastify": "^5",
|
|
32
|
-
"@naturalcycles/dev-lib": "
|
|
32
|
+
"@naturalcycles/dev-lib": "18.4.2"
|
|
33
33
|
},
|
|
34
34
|
"exports": {
|
|
35
35
|
".": "./dist/index.js",
|
|
@@ -1,4 +1,6 @@
|
|
|
1
|
+
import { _filterUndefinedValues } from '@naturalcycles/js-lib/object'
|
|
1
2
|
import type {
|
|
3
|
+
AnyObject,
|
|
2
4
|
NonNegativeInteger,
|
|
3
5
|
NumberOfMilliseconds,
|
|
4
6
|
NumberOfSeconds,
|
|
@@ -6,7 +8,7 @@ import type {
|
|
|
6
8
|
UnixTimestamp,
|
|
7
9
|
} from '@naturalcycles/js-lib/types'
|
|
8
10
|
|
|
9
|
-
export interface
|
|
11
|
+
export interface CloudRunConfig {
|
|
10
12
|
//
|
|
11
13
|
// GCP settings
|
|
12
14
|
//
|
|
@@ -15,7 +17,7 @@ export interface CloudRunDeployInfo {
|
|
|
15
17
|
* Name of the Cloud Run service.
|
|
16
18
|
*/
|
|
17
19
|
cloudRunService: string
|
|
18
|
-
cloudRunServiceBase
|
|
20
|
+
cloudRunServiceBase?: string // todo: review
|
|
19
21
|
runtimeServiceAccount: string
|
|
20
22
|
/**
|
|
21
23
|
* GCP region where the Cloud Run service is deployed. Example: 'europe-west1'
|
|
@@ -89,18 +91,6 @@ export interface CloudRunStartupProbeConfig {
|
|
|
89
91
|
periodSeconds: NumberOfSeconds
|
|
90
92
|
}
|
|
91
93
|
|
|
92
|
-
/**
|
|
93
|
-
* Experimental, subject to change.
|
|
94
|
-
*/
|
|
95
|
-
export const defaultStartupProbeConfig: CloudRunStartupProbeConfig = {
|
|
96
|
-
'httpGet.path': '/',
|
|
97
|
-
'httpGet.port': 8080,
|
|
98
|
-
initialDelaySeconds: 3,
|
|
99
|
-
failureThreshold: 50,
|
|
100
|
-
timeoutSeconds: 1,
|
|
101
|
-
periodSeconds: 2,
|
|
102
|
-
}
|
|
103
|
-
|
|
104
94
|
export interface CloudRunEnv {
|
|
105
95
|
APP_ENV: string
|
|
106
96
|
/**
|
|
@@ -138,3 +128,30 @@ export interface CloudRunEnv {
|
|
|
138
128
|
OTEL_EXPORTER_OTLP_ENDPOINT?: string
|
|
139
129
|
OTEL_LOG_LEVEL?: 'INFO' | 'DEBUG'
|
|
140
130
|
}
|
|
131
|
+
|
|
132
|
+
/**
|
|
133
|
+
* @experimental
|
|
134
|
+
*/
|
|
135
|
+
class CloudRunService {
|
|
136
|
+
/**
|
|
137
|
+
* Turns an object into a string representation where each
|
|
138
|
+
* key-value pair is represented as `key1=value1,key2=value2,...`.
|
|
139
|
+
*/
|
|
140
|
+
stringifyObject(obj: AnyObject): string {
|
|
141
|
+
const filteredObj = _filterUndefinedValues(obj)
|
|
142
|
+
return Object.entries(filteredObj)
|
|
143
|
+
.map(([key, value]) => `${key}=${value}`)
|
|
144
|
+
.join(',')
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
readonly defaultStartupProbeConfig: CloudRunStartupProbeConfig = {
|
|
148
|
+
'httpGet.path': '/',
|
|
149
|
+
'httpGet.port': 8080,
|
|
150
|
+
initialDelaySeconds: 3,
|
|
151
|
+
failureThreshold: 50,
|
|
152
|
+
timeoutSeconds: 1,
|
|
153
|
+
periodSeconds: 2,
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
export const cloudRunService = new CloudRunService()
|