@boostercloud/framework-provider-azure 3.1.2 → 3.2.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.
package/dist/constants.d.ts
CHANGED
|
@@ -28,6 +28,7 @@ export declare const environmentVarNames: {
|
|
|
28
28
|
readonly eventHubMaxRetries: "EVENTHUB_MAX_RETRIES";
|
|
29
29
|
readonly eventHubMode: "EVENTHUB_MODE";
|
|
30
30
|
readonly rocketFunctionAppNames: "ROCKET_FUNCTION_APP_NAMES";
|
|
31
|
+
readonly rocketPackageMapping: "ROCKET_PACKAGE_MAPPING";
|
|
31
32
|
};
|
|
32
33
|
export declare const AZURE_CONFLICT_ERROR_CODE = 409;
|
|
33
34
|
export declare const AZURE_PRECONDITION_FAILED_ERROR = 412;
|
package/dist/constants.js
CHANGED
|
@@ -30,6 +30,7 @@ exports.environmentVarNames = {
|
|
|
30
30
|
eventHubMaxRetries: 'EVENTHUB_MAX_RETRIES',
|
|
31
31
|
eventHubMode: 'EVENTHUB_MODE',
|
|
32
32
|
rocketFunctionAppNames: 'ROCKET_FUNCTION_APP_NAMES',
|
|
33
|
+
rocketPackageMapping: 'ROCKET_PACKAGE_MAPPING',
|
|
33
34
|
};
|
|
34
35
|
// Azure special error codes
|
|
35
36
|
exports.AZURE_CONFLICT_ERROR_CODE = 409;
|
package/dist/index.js
CHANGED
|
@@ -102,6 +102,7 @@ const Provider = (rockets) => ({
|
|
|
102
102
|
api: {
|
|
103
103
|
requestSucceeded: api_adapter_1.requestSucceeded,
|
|
104
104
|
requestFailed: api_adapter_1.requestFailed,
|
|
105
|
+
healthRequestResult: api_adapter_1.healthRequestResult,
|
|
105
106
|
},
|
|
106
107
|
connections: {
|
|
107
108
|
storeData: connections_adapter_1.storeConnectionData.bind(null, cosmosClient),
|
|
@@ -11,3 +11,4 @@ export interface ContextResponse {
|
|
|
11
11
|
}
|
|
12
12
|
export declare function requestSucceeded(body?: unknown, headers?: Record<string, number | string | ReadonlyArray<string>>): Promise<ContextResponse | void>;
|
|
13
13
|
export declare function requestFailed(error: Error): Promise<ContextResponse>;
|
|
14
|
+
export declare function healthRequestResult(body: unknown, isHealthy: boolean): Promise<ContextResponse>;
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.requestSucceeded = requestSucceeded;
|
|
4
4
|
exports.requestFailed = requestFailed;
|
|
5
|
+
exports.healthRequestResult = healthRequestResult;
|
|
5
6
|
const framework_types_1 = require("@boostercloud/framework-types");
|
|
6
7
|
const WEB_SOCKET_PROTOCOL_HEADER = 'Sec-WebSocket-Protocol';
|
|
7
8
|
async function requestSucceeded(body, headers) {
|
|
@@ -39,3 +40,13 @@ async function requestFailed(error) {
|
|
|
39
40
|
}),
|
|
40
41
|
};
|
|
41
42
|
}
|
|
43
|
+
async function healthRequestResult(body, isHealthy) {
|
|
44
|
+
return {
|
|
45
|
+
headers: {
|
|
46
|
+
'Access-Control-Allow-Origin': '*',
|
|
47
|
+
'Content-Type': 'application/json',
|
|
48
|
+
},
|
|
49
|
+
status: isHealthy ? 200 : 503,
|
|
50
|
+
body: JSON.stringify(body),
|
|
51
|
+
};
|
|
52
|
+
}
|
|
@@ -99,11 +99,20 @@ async function isRocketFunctionUp(rocketFunctionAppName) {
|
|
|
99
99
|
}
|
|
100
100
|
}
|
|
101
101
|
async function areRocketFunctionsUp() {
|
|
102
|
-
|
|
103
|
-
const
|
|
104
|
-
|
|
102
|
+
const mappingString = process.env[constants_1.environmentVarNames.rocketPackageMapping] || '';
|
|
103
|
+
const rocketPackageMapping = mappingString
|
|
104
|
+
.split(';')
|
|
105
|
+
.filter(Boolean)
|
|
106
|
+
.reduce((acc, pair) => {
|
|
107
|
+
const [pkg, func] = pair.split(':');
|
|
108
|
+
if (pkg && func) {
|
|
109
|
+
acc[pkg] = func;
|
|
110
|
+
}
|
|
111
|
+
return acc;
|
|
112
|
+
}, {});
|
|
113
|
+
const results = await Promise.all(Object.entries(rocketPackageMapping).map(async ([packageName, functionAppName]) => {
|
|
105
114
|
const isUp = await isRocketFunctionUp(functionAppName);
|
|
106
|
-
return { [
|
|
115
|
+
return { [packageName]: isUp };
|
|
107
116
|
}));
|
|
108
117
|
return results.reduce((acc, result) => ({ ...acc, ...result }), {});
|
|
109
118
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@boostercloud/framework-provider-azure",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.2.0",
|
|
4
4
|
"description": "Handle Booster's integration with Azure",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"framework-provider-azure"
|
|
@@ -27,14 +27,14 @@
|
|
|
27
27
|
"@azure/functions": "^1.2.2",
|
|
28
28
|
"@azure/identity": "~4.7.0",
|
|
29
29
|
"@azure/event-hubs": "5.11.1",
|
|
30
|
-
"@boostercloud/framework-common-helpers": "^3.
|
|
31
|
-
"@boostercloud/framework-types": "^3.
|
|
30
|
+
"@boostercloud/framework-common-helpers": "^3.2.0",
|
|
31
|
+
"@boostercloud/framework-types": "^3.2.0",
|
|
32
32
|
"tslib": "^2.4.0",
|
|
33
33
|
"@effect-ts/core": "^0.60.4",
|
|
34
34
|
"@azure/web-pubsub": "~1.1.0"
|
|
35
35
|
},
|
|
36
36
|
"devDependencies": {
|
|
37
|
-
"@boostercloud/eslint-config": "^3.
|
|
37
|
+
"@boostercloud/eslint-config": "^3.2.0",
|
|
38
38
|
"@types/chai": "4.2.18",
|
|
39
39
|
"@types/chai-as-promised": "7.1.4",
|
|
40
40
|
"@types/faker": "5.1.5",
|