@magek/server 0.0.6 → 0.0.7
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/index.js +6 -11
- package/dist/infrastructure/controllers/graphql.js +1 -0
- package/dist/infrastructure/controllers/health-controller.js +1 -0
- package/dist/infrastructure/test-helper/local-test-helper.js +2 -0
- package/dist/infrastructure/websocket-registry.js +1 -3
- package/dist/library/graphql-adapter.js +5 -5
- package/dist/library/health-adapter.js +2 -2
- package/dist/services/graphql-service.js +1 -0
- package/dist/services/health-service.js +1 -0
- package/package.json +5 -5
package/dist/index.js
CHANGED
|
@@ -46,42 +46,37 @@ exports.ServerRuntime = {
|
|
|
46
46
|
},
|
|
47
47
|
sensor: {
|
|
48
48
|
databaseEventsHealthDetails: (config) => {
|
|
49
|
-
var _a;
|
|
50
49
|
// Delegate to event store adapter health check if available
|
|
51
|
-
if (
|
|
50
|
+
if (config.eventStoreAdapter?.healthCheck) {
|
|
52
51
|
return config.eventStoreAdapter.healthCheck.details(config);
|
|
53
52
|
}
|
|
54
53
|
throw new Error('No event store adapter configured for health checks');
|
|
55
54
|
},
|
|
56
55
|
databaseReadModelsHealthDetails: (config) => {
|
|
57
|
-
var _a;
|
|
58
56
|
// Delegate to read model store adapter health check if available
|
|
59
|
-
if (
|
|
57
|
+
if (config.readModelStoreAdapter?.healthCheck) {
|
|
60
58
|
return config.readModelStoreAdapter.healthCheck.details(config);
|
|
61
59
|
}
|
|
62
60
|
throw new Error('No read model store adapter configured for health checks');
|
|
63
61
|
},
|
|
64
62
|
isDatabaseEventUp: (config) => {
|
|
65
|
-
var _a;
|
|
66
63
|
// Delegate to event store adapter health check if available
|
|
67
|
-
if (
|
|
64
|
+
if (config.eventStoreAdapter?.healthCheck) {
|
|
68
65
|
return config.eventStoreAdapter.healthCheck.isUp(config);
|
|
69
66
|
}
|
|
70
67
|
return Promise.resolve(false);
|
|
71
68
|
},
|
|
72
69
|
areDatabaseReadModelsUp: (config) => {
|
|
73
|
-
var _a;
|
|
74
70
|
// Delegate to read model store adapter health check if available
|
|
75
|
-
if (
|
|
71
|
+
if (config.readModelStoreAdapter?.healthCheck) {
|
|
76
72
|
return config.readModelStoreAdapter.healthCheck.isUp(config);
|
|
77
73
|
}
|
|
78
74
|
return Promise.resolve(false);
|
|
79
75
|
},
|
|
80
76
|
databaseUrls: (config) => {
|
|
81
|
-
var _a, _b, _c, _d, _e, _f;
|
|
82
77
|
// Get URLs from both event store and read model store adapters
|
|
83
|
-
const eventUrls =
|
|
84
|
-
const readModelUrls =
|
|
78
|
+
const eventUrls = config.eventStoreAdapter?.healthCheck?.urls(config) ?? Promise.resolve([]);
|
|
79
|
+
const readModelUrls = config.readModelStoreAdapter?.healthCheck?.urls(config) ?? Promise.resolve([]);
|
|
85
80
|
return Promise.all([eventUrls, readModelUrls]).then(([events, readModels]) => [
|
|
86
81
|
...events,
|
|
87
82
|
...readModels
|
|
@@ -3,6 +3,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.LocalTestHelper = void 0;
|
|
4
4
|
const local_queries_1 = require("./local-queries");
|
|
5
5
|
class LocalTestHelper {
|
|
6
|
+
outputs;
|
|
7
|
+
queries;
|
|
6
8
|
constructor(outputs, queries) {
|
|
7
9
|
this.outputs = outputs;
|
|
8
10
|
this.queries = queries;
|
|
@@ -13,16 +13,16 @@ function webSocketMessageToEnvelope(config, webSocketRequest, requestID) {
|
|
|
13
13
|
logger.debug('Received WebSocket GraphQL request: ', webSocketRequest);
|
|
14
14
|
let eventType = 'MESSAGE';
|
|
15
15
|
const incomingMessage = webSocketRequest.incomingMessage;
|
|
16
|
-
const headers = incomingMessage
|
|
16
|
+
const headers = incomingMessage?.headers;
|
|
17
17
|
const data = webSocketRequest.data;
|
|
18
18
|
try {
|
|
19
19
|
const connectionContext = webSocketRequest.connectionContext;
|
|
20
|
-
eventType = connectionContext
|
|
20
|
+
eventType = connectionContext?.eventType;
|
|
21
21
|
return {
|
|
22
22
|
requestID,
|
|
23
23
|
eventType,
|
|
24
|
-
connectionID: connectionContext
|
|
25
|
-
token: Array.isArray(headers
|
|
24
|
+
connectionID: connectionContext?.connectionId.toString(),
|
|
25
|
+
token: Array.isArray(headers?.authorization) ? headers.authorization[0] : headers?.authorization,
|
|
26
26
|
value: data,
|
|
27
27
|
context: {
|
|
28
28
|
request: {
|
|
@@ -60,7 +60,7 @@ function httpMessageToEnvelope(config, httpRequest, requestId) {
|
|
|
60
60
|
connectionID: undefined,
|
|
61
61
|
requestID: requestId,
|
|
62
62
|
eventType: eventType,
|
|
63
|
-
token: Array.isArray(headers
|
|
63
|
+
token: Array.isArray(headers?.authorization) ? headers.authorization[0] : headers?.authorization,
|
|
64
64
|
value: data,
|
|
65
65
|
context: {
|
|
66
66
|
request: {
|
|
@@ -15,7 +15,7 @@ async function databaseUrl() {
|
|
|
15
15
|
async function countAll(database) {
|
|
16
16
|
await database.loadDatabaseAsync();
|
|
17
17
|
const count = await database.countAsync({});
|
|
18
|
-
return count
|
|
18
|
+
return count ?? 0;
|
|
19
19
|
}
|
|
20
20
|
async function graphqlFunctionUrl() {
|
|
21
21
|
try {
|
|
@@ -65,6 +65,6 @@ function rawRequestToSensorHealth(rawRequest) {
|
|
|
65
65
|
rawContext: rawRequest,
|
|
66
66
|
},
|
|
67
67
|
componentPath: componentPath,
|
|
68
|
-
token: Array.isArray(headers
|
|
68
|
+
token: Array.isArray(headers?.authorization) ? headers.authorization[0] : headers?.authorization,
|
|
69
69
|
};
|
|
70
70
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@magek/server",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.7",
|
|
4
4
|
"description": "Debug your Magek projects locally",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"server"
|
|
@@ -26,12 +26,12 @@
|
|
|
26
26
|
"node": ">=22.0.0 <23.0.0"
|
|
27
27
|
},
|
|
28
28
|
"dependencies": {
|
|
29
|
-
"@magek/common": "^0.0.
|
|
29
|
+
"@magek/common": "^0.0.7",
|
|
30
30
|
"@fastify/cors": "11.2.0",
|
|
31
31
|
"@fastify/websocket": "11.2.0",
|
|
32
32
|
"@seald-io/nedb": "4.1.2",
|
|
33
|
-
"fastify": "5.7.
|
|
34
|
-
"fastify-sse-v2": "4.2.
|
|
33
|
+
"fastify": "5.7.2",
|
|
34
|
+
"fastify-sse-v2": "4.2.2",
|
|
35
35
|
"node-schedule": "2.1.1",
|
|
36
36
|
"tslib": "2.8.1"
|
|
37
37
|
},
|
|
@@ -39,7 +39,7 @@
|
|
|
39
39
|
"url": "https://github.com/theam/magek/issues"
|
|
40
40
|
},
|
|
41
41
|
"devDependencies": {
|
|
42
|
-
"@magek/eslint-config": "^0.0.
|
|
42
|
+
"@magek/eslint-config": "^0.0.7",
|
|
43
43
|
"@types/chai": "5.2.3",
|
|
44
44
|
"@types/chai-as-promised": "8.0.2",
|
|
45
45
|
"@types/mocha": "10.0.10",
|