@valentine-efagene/qshelter-common 2.0.18 → 2.0.19
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.
|
@@ -15,6 +15,13 @@ export interface InfrastructureConfig {
|
|
|
15
15
|
export interface JwtSecrets {
|
|
16
16
|
secret: string;
|
|
17
17
|
}
|
|
18
|
+
export interface DatabaseCredentials {
|
|
19
|
+
username: string;
|
|
20
|
+
password: string;
|
|
21
|
+
host: string;
|
|
22
|
+
port: number;
|
|
23
|
+
database: string;
|
|
24
|
+
}
|
|
18
25
|
export interface EncryptionSecrets {
|
|
19
26
|
password: string;
|
|
20
27
|
salt: string;
|
|
@@ -60,6 +67,11 @@ export declare class ConfigService {
|
|
|
60
67
|
* Get refresh token secret from Secrets Manager
|
|
61
68
|
*/
|
|
62
69
|
getRefreshTokenSecret(stage?: string): Promise<JwtSecrets>;
|
|
70
|
+
/**
|
|
71
|
+
* Get database credentials - combines secret and infrastructure config
|
|
72
|
+
* Returns a complete DatabaseCredentials object ready to use
|
|
73
|
+
*/
|
|
74
|
+
getDatabaseCredentials(stage?: string): Promise<DatabaseCredentials>;
|
|
63
75
|
/**
|
|
64
76
|
* Get encryption secrets from Secrets Manager
|
|
65
77
|
*/
|
|
@@ -90,6 +90,27 @@ export class ConfigService {
|
|
|
90
90
|
async getRefreshTokenSecret(stage = process.env.NODE_ENV || 'dev') {
|
|
91
91
|
return this.getSecret(`qshelter/${stage}/refresh-token-secret`);
|
|
92
92
|
}
|
|
93
|
+
/**
|
|
94
|
+
* Get database credentials - combines secret and infrastructure config
|
|
95
|
+
* Returns a complete DatabaseCredentials object ready to use
|
|
96
|
+
*/
|
|
97
|
+
async getDatabaseCredentials(stage = process.env.NODE_ENV || 'dev') {
|
|
98
|
+
const cacheKey = `db-credentials-${stage}`;
|
|
99
|
+
const cached = this.getFromCache(cacheKey);
|
|
100
|
+
if (cached)
|
|
101
|
+
return cached;
|
|
102
|
+
const infraConfig = await this.getInfrastructureConfig(stage);
|
|
103
|
+
const dbSecret = await this.getSecret(infraConfig.databaseSecretArn);
|
|
104
|
+
const credentials = {
|
|
105
|
+
username: dbSecret.username,
|
|
106
|
+
password: dbSecret.password,
|
|
107
|
+
host: infraConfig.dbHost,
|
|
108
|
+
port: infraConfig.dbPort,
|
|
109
|
+
database: `qshelter_${stage}`,
|
|
110
|
+
};
|
|
111
|
+
this.setCache(cacheKey, credentials);
|
|
112
|
+
return credentials;
|
|
113
|
+
}
|
|
93
114
|
/**
|
|
94
115
|
* Get encryption secrets from Secrets Manager
|
|
95
116
|
*/
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@valentine-efagene/qshelter-common",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.19",
|
|
4
4
|
"description": "Shared database schemas and utilities for QShelter services",
|
|
5
5
|
"main": "dist/src/index.js",
|
|
6
6
|
"types": "dist/src/index.d.ts",
|
|
@@ -28,12 +28,13 @@
|
|
|
28
28
|
"prisma"
|
|
29
29
|
],
|
|
30
30
|
"dependencies": {
|
|
31
|
-
"@
|
|
32
|
-
"prisma": "^7.0.0",
|
|
31
|
+
"@aws-sdk/client-secrets-manager": "^3.500.0",
|
|
33
32
|
"@aws-sdk/client-ssm": "^3.500.0",
|
|
34
|
-
"@
|
|
33
|
+
"@prisma/client": "^7.0.0",
|
|
34
|
+
"prisma": "^7.0.0"
|
|
35
35
|
},
|
|
36
36
|
"devDependencies": {
|
|
37
|
+
"@types/node": "^25.0.3",
|
|
37
38
|
"typescript": "^5.7.3"
|
|
38
39
|
}
|
|
39
40
|
}
|