@friggframework/core 2.0.0--canary.482.bda352c.0 → 2.0.0--canary.487.d3468e8.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.
@@ -76,9 +76,10 @@ class HealthCheckRepositoryInterface {
76
76
  /**
77
77
  * Get database connection state
78
78
  *
79
- * @returns {Object} Connection state info
79
+ * @returns {Promise<Object>} Connection state info
80
+ * @abstract
80
81
  */
81
- getDatabaseConnectionState() {
82
+ async getDatabaseConnectionState() {
82
83
  throw new Error('Method getDatabaseConnectionState must be implemented by subclass');
83
84
  }
84
85
  }
@@ -8,32 +8,42 @@ const {
8
8
  * MongoDB-specific Health Check Repository
9
9
  *
10
10
  * Provides MongoDB-specific database operations for health testing.
11
- * Uses Mongoose for MongoDB-specific operations (raw access, ping).
11
+ * Uses Prisma for MongoDB operations (Mongoose is legacy/unused).
12
12
  */
13
13
  class HealthCheckRepositoryMongoDB extends HealthCheckRepositoryInterface {
14
14
  constructor() {
15
15
  super();
16
16
  }
17
17
 
18
- getDatabaseConnectionState() {
19
- const stateMap = {
20
- 0: 'disconnected',
21
- 1: 'connected',
22
- 2: 'connecting',
23
- 3: 'disconnecting',
24
- };
25
- const readyState = mongoose.connection.readyState;
18
+ async getDatabaseConnectionState() {
19
+ // Prisma doesn't expose connection state like Mongoose
20
+ // We need to actually test the connection
21
+ let isConnected = false;
22
+ let stateName = 'unknown';
23
+
24
+ try {
25
+ // Try a quick query to see if we're connected
26
+ await prisma.$runCommandRaw({ ping: 1 });
27
+ isConnected = true;
28
+ stateName = 'connected';
29
+ } catch (error) {
30
+ stateName = 'disconnected';
31
+ }
26
32
 
27
33
  return {
28
- readyState,
29
- stateName: stateMap[readyState],
30
- isConnected: readyState === 1,
34
+ readyState: isConnected ? 1 : 0,
35
+ stateName,
36
+ isConnected,
31
37
  };
32
38
  }
33
39
 
34
40
  async pingDatabase(maxTimeMS = 2000) {
35
41
  const pingStart = Date.now();
36
- await mongoose.connection.db.admin().ping({ maxTimeMS });
42
+ // Use Prisma's $queryRaw to execute a ping command
43
+ await prisma.$queryRaw`SELECT 1`.catch(() => {
44
+ // For MongoDB, use runCommandRaw instead
45
+ return prisma.$runCommandRaw({ ping: 1 });
46
+ });
37
47
  return Date.now() - pingStart;
38
48
  }
39
49
 
@@ -14,14 +14,25 @@ class HealthCheckRepositoryPostgreSQL extends HealthCheckRepositoryInterface {
14
14
  super();
15
15
  }
16
16
 
17
- getDatabaseConnectionState() {
17
+ async getDatabaseConnectionState() {
18
18
  // PostgreSQL connection state via Prisma
19
- // Note: Prisma doesn't expose connection state like Mongoose
20
- // We check if prisma is connected by attempting a query
19
+ // Prisma doesn't expose connection state, so we test it
20
+ let isConnected = false;
21
+ let stateName = 'unknown';
22
+
23
+ try {
24
+ // Try a quick query to see if we're connected
25
+ await prisma.$queryRaw`SELECT 1`;
26
+ isConnected = true;
27
+ stateName = 'connected';
28
+ } catch (error) {
29
+ stateName = 'disconnected';
30
+ }
31
+
21
32
  return {
22
- readyState: 1, // Assume connected if Prisma instance exists
23
- stateName: 'connected',
24
- isConnected: true,
33
+ readyState: isConnected ? 1 : 0,
34
+ stateName,
35
+ isConnected,
25
36
  };
26
37
  }
27
38
 
@@ -16,7 +16,7 @@ class CheckDatabaseHealthUseCase {
16
16
  * @returns {Promise<Object>} Health check result with status, state, and response time
17
17
  */
18
18
  async execute() {
19
- const { stateName, isConnected } = this.repository.getDatabaseConnectionState();
19
+ const { stateName, isConnected } = await this.repository.getDatabaseConnectionState();
20
20
 
21
21
  const result = {
22
22
  status: isConnected ? 'healthy' : 'unhealthy',
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@friggframework/core",
3
3
  "prettier": "@friggframework/prettier-config",
4
- "version": "2.0.0--canary.482.bda352c.0",
4
+ "version": "2.0.0--canary.487.d3468e8.0",
5
5
  "dependencies": {
6
6
  "@aws-sdk/client-apigatewaymanagementapi": "^3.588.0",
7
7
  "@aws-sdk/client-kms": "^3.588.0",
@@ -38,9 +38,9 @@
38
38
  }
39
39
  },
40
40
  "devDependencies": {
41
- "@friggframework/eslint-config": "2.0.0--canary.482.bda352c.0",
42
- "@friggframework/prettier-config": "2.0.0--canary.482.bda352c.0",
43
- "@friggframework/test": "2.0.0--canary.482.bda352c.0",
41
+ "@friggframework/eslint-config": "2.0.0--canary.487.d3468e8.0",
42
+ "@friggframework/prettier-config": "2.0.0--canary.487.d3468e8.0",
43
+ "@friggframework/test": "2.0.0--canary.487.d3468e8.0",
44
44
  "@prisma/client": "^6.17.0",
45
45
  "@types/lodash": "4.17.15",
46
46
  "@typescript-eslint/eslint-plugin": "^8.0.0",
@@ -80,5 +80,5 @@
80
80
  "publishConfig": {
81
81
  "access": "public"
82
82
  },
83
- "gitHead": "bda352ca5630e5880fc4d75a1e84bb1157a6caf3"
83
+ "gitHead": "d3468e8a1e264ef2d97be6704059debc9b3ba247"
84
84
  }