@magek/adapter-session-store-nedb 0.0.6 → 0.0.8

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.
@@ -5,49 +5,9 @@ const common_1 = require("@magek/common");
5
5
  const web_socket_registry_1 = require("./web-socket-registry");
6
6
  const paths_1 = require("./paths");
7
7
  class NedbSessionStoreAdapter {
8
+ connectionRegistry;
9
+ subscriptionRegistry;
8
10
  constructor() {
9
- this.healthCheck = {
10
- isUp: async (config) => {
11
- try {
12
- // Test both registries by doing a simple count operation
13
- await this.connectionRegistry.count();
14
- await this.subscriptionRegistry.count();
15
- return true;
16
- }
17
- catch (error) {
18
- return false;
19
- }
20
- },
21
- details: async (config) => {
22
- try {
23
- const connectionsCount = await this.connectionRegistry.count();
24
- const subscriptionsCount = await this.subscriptionRegistry.count();
25
- return {
26
- status: 'healthy',
27
- connections: {
28
- count: connectionsCount,
29
- database: (0, paths_1.connectionsDatabase)()
30
- },
31
- subscriptions: {
32
- count: subscriptionsCount,
33
- database: (0, paths_1.subscriptionsDatabase)()
34
- }
35
- };
36
- }
37
- catch (error) {
38
- return {
39
- status: 'unhealthy',
40
- error: error instanceof Error ? error.message : 'Unknown error'
41
- };
42
- }
43
- },
44
- urls: async (config) => {
45
- return [
46
- `file://${(0, paths_1.connectionsDatabase)()}`,
47
- `file://${(0, paths_1.subscriptionsDatabase)()}`
48
- ];
49
- }
50
- };
51
11
  this.connectionRegistry = new web_socket_registry_1.WebSocketRegistry((0, paths_1.connectionsDatabase)());
52
12
  this.subscriptionRegistry = new web_socket_registry_1.WebSocketRegistry((0, paths_1.subscriptionsDatabase)());
53
13
  }
@@ -134,5 +94,47 @@ class NedbSessionStoreAdapter {
134
94
  const removed = await this.subscriptionRegistry.delete({ connectionID: connectionId });
135
95
  logger.debug(`Deleted ${removed} subscriptions for connection:`, connectionId);
136
96
  }
97
+ healthCheck = {
98
+ isUp: async (config) => {
99
+ try {
100
+ // Test both registries by doing a simple count operation
101
+ await this.connectionRegistry.count();
102
+ await this.subscriptionRegistry.count();
103
+ return true;
104
+ }
105
+ catch (error) {
106
+ return false;
107
+ }
108
+ },
109
+ details: async (config) => {
110
+ try {
111
+ const connectionsCount = await this.connectionRegistry.count();
112
+ const subscriptionsCount = await this.subscriptionRegistry.count();
113
+ return {
114
+ status: 'healthy',
115
+ connections: {
116
+ count: connectionsCount,
117
+ database: (0, paths_1.connectionsDatabase)()
118
+ },
119
+ subscriptions: {
120
+ count: subscriptionsCount,
121
+ database: (0, paths_1.subscriptionsDatabase)()
122
+ }
123
+ };
124
+ }
125
+ catch (error) {
126
+ return {
127
+ status: 'unhealthy',
128
+ error: error instanceof Error ? error.message : 'Unknown error'
129
+ };
130
+ }
131
+ },
132
+ urls: async (config) => {
133
+ return [
134
+ `file://${(0, paths_1.connectionsDatabase)()}`,
135
+ `file://${(0, paths_1.subscriptionsDatabase)()}`
136
+ ];
137
+ }
138
+ };
137
139
  }
138
140
  exports.NedbSessionStoreAdapter = NedbSessionStoreAdapter;
@@ -3,8 +3,9 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.WebSocketRegistry = void 0;
4
4
  const DataStore = require('@seald-io/nedb');
5
5
  class WebSocketRegistry {
6
+ datastore;
7
+ isLoaded = false;
6
8
  constructor(databasePath) {
7
- this.isLoaded = false;
8
9
  this.datastore = new DataStore({ filename: databasePath });
9
10
  }
10
11
  async loadDatabaseIfNeeded() {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@magek/adapter-session-store-nedb",
3
- "version": "0.0.6",
3
+ "version": "0.0.8",
4
4
  "description": "Nedb-based session store adapter for the Magek framework",
5
5
  "keywords": [
6
6
  "session-store",
@@ -27,7 +27,7 @@
27
27
  "node": ">=22.0.0 <23.0.0"
28
28
  },
29
29
  "dependencies": {
30
- "@magek/common": "^0.0.6",
30
+ "@magek/common": "^0.0.8",
31
31
  "@seald-io/nedb": "4.1.2",
32
32
  "tslib": "2.8.1"
33
33
  },
@@ -35,7 +35,7 @@
35
35
  "url": "https://github.com/theam/magek/issues"
36
36
  },
37
37
  "devDependencies": {
38
- "@magek/eslint-config": "^0.0.6",
38
+ "@magek/eslint-config": "^0.0.8",
39
39
  "@types/chai": "5.2.3",
40
40
  "@types/chai-as-promised": "8.0.2",
41
41
  "@types/mocha": "10.0.10",