@elsikora/nestjs-typeorm-aws-connector 1.0.1
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/LICENSE +21 -0
- package/README.md +213 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.js +20 -0
- package/dist/index.js.map +1 -0
- package/dist/modules/database/database.module.d.ts +7 -0
- package/dist/modules/database/database.module.js +63 -0
- package/dist/modules/database/database.module.js.map +1 -0
- package/dist/modules/database/database.service.d.ts +28 -0
- package/dist/modules/database/database.service.js +72 -0
- package/dist/modules/database/database.service.js.map +1 -0
- package/dist/modules/database/index.d.ts +3 -0
- package/dist/modules/database/index.js +20 -0
- package/dist/modules/database/index.js.map +1 -0
- package/dist/modules/database/rotator/rotator.service.d.ts +13 -0
- package/dist/modules/database/rotator/rotator.service.js +61 -0
- package/dist/modules/database/rotator/rotator.service.js.map +1 -0
- package/dist/shared/constant/database/constant.d.ts +15 -0
- package/dist/shared/constant/database/constant.js +30 -0
- package/dist/shared/constant/database/constant.js.map +1 -0
- package/dist/shared/enum/database/type.enum.d.ts +4 -0
- package/dist/shared/enum/database/type.enum.js +9 -0
- package/dist/shared/enum/database/type.enum.js.map +1 -0
- package/dist/shared/interface/aws/secrets-manager/item.interface.d.ts +4 -0
- package/dist/shared/interface/aws/secrets-manager/item.interface.js +3 -0
- package/dist/shared/interface/aws/secrets-manager/item.interface.js.map +1 -0
- package/dist/shared/interface/database/config.interface.d.ts +15 -0
- package/dist/shared/interface/database/config.interface.js +3 -0
- package/dist/shared/interface/database/config.interface.js.map +1 -0
- package/dist/shared/interface/database/module-async-options.interface.d.ts +7 -0
- package/dist/shared/interface/database/module-async-options.interface.js +3 -0
- package/dist/shared/interface/database/module-async-options.interface.js.map +1 -0
- package/dist/shared/interface/database/module-options.interface.d.ts +2 -0
- package/dist/shared/interface/database/module-options.interface.js +3 -0
- package/dist/shared/interface/database/module-options.interface.js.map +1 -0
- package/dist/shared/provider/database/database.provider.d.ts +4 -0
- package/dist/shared/provider/database/database.provider.js +13 -0
- package/dist/shared/provider/database/database.provider.js.map +1 -0
- package/dist/shared/type/database/config-rotation.type.d.ts +6 -0
- package/dist/shared/type/database/config-rotation.type.js +3 -0
- package/dist/shared/type/database/config-rotation.type.js.map +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -0
- package/package.json +96 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024 ElsiKora
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,213 @@
|
|
|
1
|
+
<p align="center">
|
|
2
|
+
<h1 align="center">NestJS TypeORM AWS Connector</h1>
|
|
3
|
+
</p>
|
|
4
|
+
|
|
5
|
+
<p align="center">
|
|
6
|
+
<img src="https://img.shields.io/github/license/ElsiKora/NestJS-TypeORM-AWS-Connector?style=for-the-badge&logo=opensourceinitiative&logoColor=white&color=0080ff" alt="license">
|
|
7
|
+
<img src="https://img.shields.io/github/last-commit/ElsiKora/NestJS-TypeORM-AWS-Connector?style=for-the-badge&logo=git&logoColor=white&color=0080ff" alt="last-commit">
|
|
8
|
+
<img src="https://img.shields.io/github/languages/top/ElsiKora/NestJS-TypeORM-AWS-Connector?style=for-the-badge&color=0080ff" alt="repo-top-language">
|
|
9
|
+
<img src="https://img.shields.io/github/languages/count/ElsiKora/NestJS-TypeORM-AWS-Connector?style=for-the-badge&color=0080ff" alt="repo-language-count">
|
|
10
|
+
</p>
|
|
11
|
+
|
|
12
|
+
<p align="center">
|
|
13
|
+
<em>Developed with the software and tools below.</em>
|
|
14
|
+
</p>
|
|
15
|
+
|
|
16
|
+
<p align="center">
|
|
17
|
+
<a aria-label="ElsiKora logo" href="https://elsikora.com">
|
|
18
|
+
<img src="https://img.shields.io/badge/MADE%20BY%20ElsiKora-212121.svg?style=for-the-badge">
|
|
19
|
+
</a>
|
|
20
|
+
<img src="https://img.shields.io/badge/Prettier-F7B93E.svg?style=for-the-badge&logo=Prettier&logoColor=black" alt="Prettier">
|
|
21
|
+
<img src="https://img.shields.io/badge/ESLint-4B32C3.svg?style=for-the-badge&logo=ESLint&logoColor=white" alt="ESLint">
|
|
22
|
+
<img src="https://img.shields.io/badge/TypeScript-3178C6.svg?style=for-the-badge&logo=TypeScript&logoColor=white" alt="TypeScript">
|
|
23
|
+
<img src="https://img.shields.io/badge/NestJS-E0234E.svg?style=for-the-badge&logo=NestJS&logoColor=white" alt="NestJS">
|
|
24
|
+
<img src="https://img.shields.io/badge/TypeORM-FE0902.svg?style=for-the-badge&logo=TypeORM&logoColor=white" alt="TypeORM">
|
|
25
|
+
</p>
|
|
26
|
+
|
|
27
|
+
## Overview
|
|
28
|
+
|
|
29
|
+
NestJS-TypeORM-AWS-Connector is a powerful integration module that provides seamless database connectivity for NestJS applications using TypeORM with AWS infrastructure. It supports automatic connection management, connection pooling, and rotation features specifically designed for AWS environments. The module simplifies database configuration and management while providing robust options for customization and optimization.
|
|
30
|
+
|
|
31
|
+
## Features
|
|
32
|
+
|
|
33
|
+
| | Feature | Description |
|
|
34
|
+
|----|------------------------|--------------------------------------------------------------------------------------------------------------------|
|
|
35
|
+
| π | **Connection Rotation** | Automatic connection rotation to prevent stale connections and ensure optimal database performance |
|
|
36
|
+
| π | **Connection Pooling** | Configurable connection pool with customizable size and timeout settings |
|
|
37
|
+
| β‘οΈ | **Performance** | Optimized database connections with configurable timeouts and idle connection management |
|
|
38
|
+
| π§ | **Easy Configuration** | Flexible configuration options through both static and async module registration |
|
|
39
|
+
| π― | **Type Safety** | Full TypeScript support with strong typing for all configuration options |
|
|
40
|
+
| π | **Multiple Databases** | Support for different database types (PostgreSQL, MySQL, etc.) through EDatabaseType enum |
|
|
41
|
+
| π | **Verbose Logging** | Optional verbose mode for detailed logging of database operations |
|
|
42
|
+
| π | **Auto-Sync Schema** | Optional automatic schema synchronization with database |
|
|
43
|
+
|
|
44
|
+
## Installation
|
|
45
|
+
|
|
46
|
+
```bash
|
|
47
|
+
npm install @elsikora/nestjs-typeorm-aws-connector
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
## Usage
|
|
51
|
+
|
|
52
|
+
### Async Configuration
|
|
53
|
+
|
|
54
|
+
```typescript
|
|
55
|
+
import { DatabaseModule } from '@elsikora/nestjs-typeorm-aws-connector';
|
|
56
|
+
import { EDatabaseType } from '@elsikora/nestjs-typeorm-aws-connector/dist/shared/enum/database/type.enum';
|
|
57
|
+
|
|
58
|
+
@Module({
|
|
59
|
+
imports: [
|
|
60
|
+
DatabaseModule.registerAsync({
|
|
61
|
+
imports: [ConfigModule],
|
|
62
|
+
inject: [ConfigService],
|
|
63
|
+
useFactory: async () => ({
|
|
64
|
+
connectionTimeoutMs: 30_000,
|
|
65
|
+
databaseName: "app",
|
|
66
|
+
entities: [Bank],
|
|
67
|
+
idleTimeoutMs: 30_000,
|
|
68
|
+
isVerbose: true,
|
|
69
|
+
poolSize: 10,
|
|
70
|
+
port: 5432,
|
|
71
|
+
rotation: {
|
|
72
|
+
intervalMs: 5000,
|
|
73
|
+
isEnabled: true,
|
|
74
|
+
},
|
|
75
|
+
shouldSynchronize: true,
|
|
76
|
+
type: EDatabaseType.POSTGRES,
|
|
77
|
+
}),
|
|
78
|
+
}),
|
|
79
|
+
]
|
|
80
|
+
})
|
|
81
|
+
export class AppModule {}
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
### Static Configuration
|
|
85
|
+
|
|
86
|
+
```typescript
|
|
87
|
+
import { DatabaseModule } from '@elsikora/nestjs-typeorm-aws-connector';
|
|
88
|
+
import { EDatabaseType } from '@elsikora/nestjs-typeorm-aws-connector/dist/shared/enum/database/type.enum';
|
|
89
|
+
|
|
90
|
+
@Module({
|
|
91
|
+
imports: [
|
|
92
|
+
DatabaseModule.register({
|
|
93
|
+
connectionTimeoutMs: 30_000,
|
|
94
|
+
databaseName: "app",
|
|
95
|
+
entities: [Bank],
|
|
96
|
+
idleTimeoutMs: 30_000,
|
|
97
|
+
isVerbose: true,
|
|
98
|
+
poolSize: 10,
|
|
99
|
+
port: 5432,
|
|
100
|
+
rotation: {
|
|
101
|
+
intervalMs: 5000,
|
|
102
|
+
isEnabled: true,
|
|
103
|
+
},
|
|
104
|
+
shouldSynchronize: true,
|
|
105
|
+
type: EDatabaseType.POSTGRES,
|
|
106
|
+
}),
|
|
107
|
+
]
|
|
108
|
+
})
|
|
109
|
+
export class AppModule {}
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
### Integration with TypeORM
|
|
113
|
+
|
|
114
|
+
```typescript
|
|
115
|
+
import { TypeOrmModule } from '@nestjs/typeorm';
|
|
116
|
+
import { DatabaseService } from '@elsikora/nestjs-typeorm-aws-connector';
|
|
117
|
+
|
|
118
|
+
@Module({
|
|
119
|
+
imports: [
|
|
120
|
+
TypeOrmModule.forRootAsync({
|
|
121
|
+
inject: [DatabaseService],
|
|
122
|
+
useFactory: async (databaseService: DatabaseService) => {
|
|
123
|
+
const options = await databaseService.getTypeOrmOptions();
|
|
124
|
+
return {
|
|
125
|
+
...options,
|
|
126
|
+
};
|
|
127
|
+
},
|
|
128
|
+
}),
|
|
129
|
+
]
|
|
130
|
+
})
|
|
131
|
+
export class AppModule {}
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
## Configuration Options
|
|
135
|
+
|
|
136
|
+
| Option | Type | Required | Default | Description |
|
|
137
|
+
|--------------------|-----------|----------|---------|----------------------------------------------------------------|
|
|
138
|
+
| type | EDatabaseType | Yes | - | Database type (POSTGRES, MYSQL, etc.) |
|
|
139
|
+
| databaseName | string | Yes | - | Name of the database to connect to |
|
|
140
|
+
| port | number | Yes | - | Database port number |
|
|
141
|
+
| entities | Entity[] | Yes | - | Array of entity classes to be loaded |
|
|
142
|
+
| poolSize | number | No | 10 | Maximum number of connections in the pool |
|
|
143
|
+
| connectionTimeoutMs| number | No | 30000 | Connection timeout in milliseconds |
|
|
144
|
+
| idleTimeoutMs | number | No | 30000 | Idle connection timeout in milliseconds |
|
|
145
|
+
| isVerbose | boolean | No | false | Enable verbose logging |
|
|
146
|
+
| shouldSynchronize | boolean | No | false | Automatically synchronize database schema |
|
|
147
|
+
| rotation.isEnabled | boolean | No | false | Enable connection rotation |
|
|
148
|
+
| rotation.intervalMs| number | No | 5000 | Connection rotation interval in milliseconds |
|
|
149
|
+
|
|
150
|
+
## Database Types
|
|
151
|
+
|
|
152
|
+
The module supports multiple database types through the `EDatabaseType` enum:
|
|
153
|
+
|
|
154
|
+
```typescript
|
|
155
|
+
enum EDatabaseType {
|
|
156
|
+
POSTGRES = 'postgres',
|
|
157
|
+
MYSQL = 'mysql',
|
|
158
|
+
}
|
|
159
|
+
```
|
|
160
|
+
|
|
161
|
+
## Services
|
|
162
|
+
|
|
163
|
+
### DatabaseService
|
|
164
|
+
|
|
165
|
+
The `DatabaseService` provides methods for managing database connections and configurations:
|
|
166
|
+
|
|
167
|
+
- `getTypeOrmOptions()`: Returns TypeORM configuration options
|
|
168
|
+
- Other utility methods for connection management
|
|
169
|
+
|
|
170
|
+
## Error Handling
|
|
171
|
+
|
|
172
|
+
The module includes built-in error handling for common database connection issues:
|
|
173
|
+
|
|
174
|
+
- Connection timeout handling
|
|
175
|
+
- Pool overflow management
|
|
176
|
+
- Rotation failures
|
|
177
|
+
- Authentication errors
|
|
178
|
+
|
|
179
|
+
## Best Practices
|
|
180
|
+
|
|
181
|
+
1. **Connection Pooling**
|
|
182
|
+
- Set appropriate `poolSize` based on your application's needs
|
|
183
|
+
- Monitor pool usage in production
|
|
184
|
+
|
|
185
|
+
2. **Connection Rotation**
|
|
186
|
+
- Enable rotation for long-running applications
|
|
187
|
+
- Adjust `rotation.intervalMs` based on your workload
|
|
188
|
+
|
|
189
|
+
3. **Timeouts**
|
|
190
|
+
- Set reasonable `connectionTimeoutMs` and `idleTimeoutMs`
|
|
191
|
+
- Consider your application's specific requirements
|
|
192
|
+
|
|
193
|
+
## Contributing
|
|
194
|
+
|
|
195
|
+
Contributions are welcome! Please feel free to submit a Pull Request. For major changes, please open an issue first to discuss what you would like to change.
|
|
196
|
+
|
|
197
|
+
1. Fork the Project
|
|
198
|
+
2. Create your Feature Branch (`git checkout -b feature/AmazingFeature`)
|
|
199
|
+
3. Commit your Changes (`git commit -m 'Add some AmazingFeature'`)
|
|
200
|
+
4. Push to the Branch (`git push origin feature/AmazingFeature`)
|
|
201
|
+
5. Open a Pull Request
|
|
202
|
+
|
|
203
|
+
## License
|
|
204
|
+
|
|
205
|
+
This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
|
|
206
|
+
|
|
207
|
+
## Support
|
|
208
|
+
|
|
209
|
+
For support, please open an issue in the GitHub repository or contact the maintainers directly.
|
|
210
|
+
|
|
211
|
+
---
|
|
212
|
+
|
|
213
|
+
Made with β₯ by [ElsiKora](https://elsikora.com)
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export * from "./modules/database";
|
|
2
|
+
export * from "./shared/constant/database/constant";
|
|
3
|
+
export type * from "./shared/interface/database/config.interface";
|
|
4
|
+
export * from "./shared/provider/database/database.provider";
|
|
5
|
+
export type * from "./shared/type/database/config-rotation.type";
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./modules/database"), exports);
|
|
18
|
+
__exportStar(require("./shared/constant/database/constant"), exports);
|
|
19
|
+
__exportStar(require("./shared/provider/database/database.provider"), exports);
|
|
20
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,qDAAmC;AACnC,sEAAoD;AAEpD,+EAA6D"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { DynamicModule } from "@nestjs/common";
|
|
2
|
+
import { IDatabaseModuleAsyncOptions } from "../../shared/interface/database/module-async-options.interface";
|
|
3
|
+
import { IDatabaseModuleOptions } from "../../shared/interface/database/module-options.interface";
|
|
4
|
+
export declare class DatabaseModule {
|
|
5
|
+
static register(config: IDatabaseModuleOptions): DynamicModule;
|
|
6
|
+
static registerAsync(options: IDatabaseModuleAsyncOptions): Promise<DynamicModule>;
|
|
7
|
+
}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var DatabaseModule_1;
|
|
9
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
+
exports.DatabaseModule = void 0;
|
|
11
|
+
const common_1 = require("@nestjs/common");
|
|
12
|
+
const schedule_1 = require("@nestjs/schedule");
|
|
13
|
+
const database_service_1 = require("./database.service");
|
|
14
|
+
const rotator_service_1 = require("./rotator/rotator.service");
|
|
15
|
+
const database_provider_1 = require("../../shared/provider/database/database.provider");
|
|
16
|
+
let DatabaseModule = DatabaseModule_1 = class DatabaseModule {
|
|
17
|
+
static register(config) {
|
|
18
|
+
const providers = [
|
|
19
|
+
{
|
|
20
|
+
provide: database_provider_1.DATABASE_CONFIG_PROVIDER,
|
|
21
|
+
useValue: config,
|
|
22
|
+
},
|
|
23
|
+
database_service_1.DatabaseService,
|
|
24
|
+
];
|
|
25
|
+
const isRotationEnabled = config.rotation?.isEnabled;
|
|
26
|
+
const imports = [];
|
|
27
|
+
if (isRotationEnabled) {
|
|
28
|
+
imports.push(schedule_1.ScheduleModule.forRoot());
|
|
29
|
+
providers.push({
|
|
30
|
+
provide: rotator_service_1.RotatorService,
|
|
31
|
+
useClass: rotator_service_1.RotatorService,
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
return {
|
|
35
|
+
module: DatabaseModule_1,
|
|
36
|
+
imports,
|
|
37
|
+
providers,
|
|
38
|
+
exports: [database_service_1.DatabaseService, ...(isRotationEnabled ? [rotator_service_1.RotatorService] : [])],
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
static async registerAsync(options) {
|
|
42
|
+
const providers = [(0, database_provider_1.createDatabaseConfigProvider)(options), database_service_1.DatabaseService];
|
|
43
|
+
const imports = [...(options.imports || [])];
|
|
44
|
+
const config = await options.useFactory(...(options.inject || []));
|
|
45
|
+
const isRotationEnabled = config.rotation?.isEnabled;
|
|
46
|
+
if (isRotationEnabled) {
|
|
47
|
+
imports.push(schedule_1.ScheduleModule.forRoot());
|
|
48
|
+
providers.push(rotator_service_1.RotatorService);
|
|
49
|
+
}
|
|
50
|
+
return {
|
|
51
|
+
module: DatabaseModule_1,
|
|
52
|
+
imports,
|
|
53
|
+
providers,
|
|
54
|
+
exports: [database_service_1.DatabaseService, ...(isRotationEnabled ? [rotator_service_1.RotatorService] : [])],
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
};
|
|
58
|
+
exports.DatabaseModule = DatabaseModule;
|
|
59
|
+
exports.DatabaseModule = DatabaseModule = DatabaseModule_1 = __decorate([
|
|
60
|
+
(0, common_1.Global)(),
|
|
61
|
+
(0, common_1.Module)({})
|
|
62
|
+
], DatabaseModule);
|
|
63
|
+
//# sourceMappingURL=database.module.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"database.module.js","sourceRoot":"","sources":["../../../src/mod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CAAC;QAErD,IAAI,iBAAiB,EAAE,CAAC;YACvB,OAAO,CAAC,IAAI,CAAC,yBAAc,CAAC,OAAO,EAAE,CAAC,CAAC;YACvC,SAAS,CAAC,IAAI,CAAC,gCAAc,CAAC,CAAC;QAChC,CAAC;QAED,OAAO;YACN,MAAM,EAAE,gBAAc;YACtB,OAAO;YACP,SAAS;YACT,OAAO,EAAE,CAAC,kCAAe,EAAE,GAAG,CAAC,iBAAiB,CAAC,CAAC,CAAC,CAAC,gCAAc,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC;SAC1E,CAAC;IACH,CAAC;CACD,CAAA;AAjDY,wCAAc;yBAAd,cAAc;IAF1B,IAAA,eAAM,GAAE;IACR,IAAA,eAAM,EAAC,EAAE,CAAC;GACE,cAAc,CAiD1B"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { ConfigService } from "@nestjs/config";
|
|
2
|
+
import { ParameterStoreConfigService } from "@elsikora/nestjs-aws-parameter-store-config";
|
|
3
|
+
import { IDatabaseConfig } from "../../shared/interface/database/config.interface";
|
|
4
|
+
import { IAwsSecretsManagerItem } from "../../shared/interface/aws/secrets-manager/item.interface";
|
|
5
|
+
export declare class DatabaseService {
|
|
6
|
+
private readonly configService;
|
|
7
|
+
private readonly parameterStoreConfigService;
|
|
8
|
+
private readonly databaseConfig;
|
|
9
|
+
private readonly logger;
|
|
10
|
+
constructor(configService: ConfigService, parameterStoreConfigService: ParameterStoreConfigService, databaseConfig: IDatabaseConfig);
|
|
11
|
+
getCredentials(): Promise<IAwsSecretsManagerItem>;
|
|
12
|
+
getTypeOrmOptions(): Promise<{
|
|
13
|
+
type: any;
|
|
14
|
+
host: string;
|
|
15
|
+
port: number;
|
|
16
|
+
username: string;
|
|
17
|
+
password: string;
|
|
18
|
+
database: string;
|
|
19
|
+
logging: boolean;
|
|
20
|
+
synchronize: boolean;
|
|
21
|
+
extra: {
|
|
22
|
+
connectionTimeoutMillis: number;
|
|
23
|
+
idleTimeoutMillis: number;
|
|
24
|
+
max: number;
|
|
25
|
+
};
|
|
26
|
+
entities: import("typeorm").MixedList<string | Function | import("typeorm").EntitySchema<any>>;
|
|
27
|
+
}>;
|
|
28
|
+
}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
+
};
|
|
11
|
+
var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
12
|
+
return function (target, key) { decorator(target, key, paramIndex); }
|
|
13
|
+
};
|
|
14
|
+
var DatabaseService_1;
|
|
15
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
16
|
+
exports.DatabaseService = void 0;
|
|
17
|
+
const common_1 = require("@nestjs/common");
|
|
18
|
+
const config_1 = require("@nestjs/config");
|
|
19
|
+
const nestjs_aws_parameter_store_config_1 = require("@elsikora/nestjs-aws-parameter-store-config");
|
|
20
|
+
const client_secrets_manager_1 = require("@aws-sdk/client-secrets-manager");
|
|
21
|
+
const database_provider_1 = require("../../shared/provider/database/database.provider");
|
|
22
|
+
let DatabaseService = DatabaseService_1 = class DatabaseService {
|
|
23
|
+
constructor(configService, parameterStoreConfigService, databaseConfig) {
|
|
24
|
+
this.configService = configService;
|
|
25
|
+
this.parameterStoreConfigService = parameterStoreConfigService;
|
|
26
|
+
this.databaseConfig = databaseConfig;
|
|
27
|
+
this.logger = new common_1.Logger(DatabaseService_1.name);
|
|
28
|
+
}
|
|
29
|
+
async getCredentials() {
|
|
30
|
+
this.logger.debug("Asking credentials from AWS Secrets Manager...");
|
|
31
|
+
const region = this.configService.get("AWS_REGION");
|
|
32
|
+
const client = new client_secrets_manager_1.SecretsManagerClient({ region });
|
|
33
|
+
const secretId = this.parameterStoreConfigService.get(`/${this.configService.get("APPLICATION")}/elastic-beanstalk/${this.configService.get("APPLICATION")}-reaper-api/aws-secrets-manager/database-credentials-secret-id`);
|
|
34
|
+
console.log("SECRETID", secretId, `/${this.configService.get("APPLICATION")}/elastic-beanstalk/${this.configService.get("APPLICATION")}-reaper-api/aws-secrets-manager/database-credentials-secret-id`);
|
|
35
|
+
const response = await client.send(new client_secrets_manager_1.GetSecretValueCommand({
|
|
36
|
+
SecretId: secretId,
|
|
37
|
+
VersionStage: "AWSCURRENT",
|
|
38
|
+
}));
|
|
39
|
+
this.logger.debug("Secrets was successfully loaded");
|
|
40
|
+
return JSON.parse(response.SecretString ?? "{}");
|
|
41
|
+
}
|
|
42
|
+
async getTypeOrmOptions() {
|
|
43
|
+
const credentials = await this.getCredentials();
|
|
44
|
+
const host = this.parameterStoreConfigService.get(`/${this.configService.get("APPLICATION")}/elastic-beanstalk/${this.configService.get("APPLICATION")}-reaper-api/aws-rds/host`);
|
|
45
|
+
const options = {
|
|
46
|
+
type: this.databaseConfig.type,
|
|
47
|
+
host,
|
|
48
|
+
port: this.databaseConfig.port,
|
|
49
|
+
username: credentials.username,
|
|
50
|
+
password: credentials.password,
|
|
51
|
+
database: this.databaseConfig.databaseName,
|
|
52
|
+
logging: this.databaseConfig.isVerbose || false,
|
|
53
|
+
synchronize: this.databaseConfig.shouldSynchronize || false,
|
|
54
|
+
extra: {
|
|
55
|
+
connectionTimeoutMillis: this.databaseConfig.connectionTimeoutMs || 30000,
|
|
56
|
+
idleTimeoutMillis: this.databaseConfig.idleTimeoutMs || 30000,
|
|
57
|
+
max: this.databaseConfig.poolSize || 10,
|
|
58
|
+
},
|
|
59
|
+
entities: this.databaseConfig.entities,
|
|
60
|
+
};
|
|
61
|
+
this.logger.debug(`TypeORM options ΡΡΠΎΡΠΌΠΈΡΠΎΠ²Π°Π½Ρ: ${JSON.stringify(options)}`);
|
|
62
|
+
return options;
|
|
63
|
+
}
|
|
64
|
+
};
|
|
65
|
+
exports.DatabaseService = DatabaseService;
|
|
66
|
+
exports.DatabaseService = DatabaseService = DatabaseService_1 = __decorate([
|
|
67
|
+
(0, common_1.Injectable)(),
|
|
68
|
+
__param(2, (0, common_1.Inject)(database_provider_1.DATABASE_CONFIG_PROVIDER)),
|
|
69
|
+
__metadata("design:paramtypes", [config_1.ConfigService,
|
|
70
|
+
nestjs_aws_parameter_store_config_1.ParameterStoreConfigService, Object])
|
|
71
|
+
], DatabaseService);
|
|
72
|
+
//# sourceMappingURL=database.service.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"database.service.js","sourceRoot":"","sources":["../../../src/modules/database/database.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,2CAA4D;AAC5D,2CAA+C;AAC/C,mGAA0F;AAC1F,4EAA8F;AAC9F,wFAAuF;AAKhF,IAAM,eAAe,uBAArB,MAAM,eAAe;IAG3B,YACkB,aAA4B,EAC5B,2BAAwD,EAEzE,cAAgD;QAH/B,kBAAa,GAAb,aAAa,CAAe;QAC5B,gCAA2B,GAA3B,2BAA2B,CAA6B;QAExD,mBAAc,GAAd,cAAc,CAAiB;QANhC,WAAM,GAAG,IAAI,eAAM,CAAC,iBAAe,CAAC,IAAI,CAAC,CAAC;IAOxD,CAAC;IAEJ,KAAK,CAAC,cAAc;QACnB,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,gDAAgD,CAAC,CAAC;QAEpE,MAAM,MAAM,GAAG,IAAI,CAAC,aAAa,CAAC,GAAG,CAAS,YAAY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AC9B,QAAQ,EAAE,WAAW,CAAC,QAAQ;YAC9B,QAAQ,EAAE,IAAI,CAAC,cAAc,CAAC,YAAY;YAC1C,OAAO,EAAE,IAAI,CAAC,cAAc,CAAC,SAAS,IAAI,KAAK;YAC/C,WAAW,EAAE,IAAI,CAAC,cAAc,CAAC,iBAAiB,IAAI,KAAK;YAC3D,KAAK,EAAE;gBACN,uBAAuB,EAAE,IAAI,CAAC,cAAc,CAAC,mBAAmB,IAAI,KAAK;gBACzE,iBAAiB,EAAE,IAAI,CAAC,cAAc,CAAC,aAAa,IAAI,KAAK;gBAC7D,GAAG,EAAE,IAAI,CAAC,cAAc,CAAC,QAAQ,IAAI,EAAE;aACvC;YACD,QAAQ,EAAE,IAAI,CAAC,cAAc,CAAC,QAAQ;SACtC,CAAC;QAEF,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,iCAAiC,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC;QAE9E,OAAO,OAAO,CAAC;IAChB,CAAC;CACD,CAAA;AA1DY,0CAAe;0BAAf,eAAe;IAD3B,IAAA,mBAAU,GAAE;IAOV,WAAA,IAAA,eAAM,EAAC,4CAAwB,CAAC,CAAA;qCAFD,sBAAa;QACC,+DAA2B;GAL9D,eAAe,CA0D3B"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./database.module"), exports);
|
|
18
|
+
__exportStar(require("./database.service"), exports);
|
|
19
|
+
__exportStar(require("./rotator/rotator.service"), exports);
|
|
20
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/modules/database/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,oDAAkC;AAClC,qDAAmC;AACnC,4DAA0C"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { OnModuleInit } from "@nestjs/common";
|
|
2
|
+
import { SchedulerRegistry } from "@nestjs/schedule";
|
|
3
|
+
import { DataSource } from "typeorm";
|
|
4
|
+
import { IDatabaseConfig } from "../../../shared/interface/database/config.interface";
|
|
5
|
+
export declare class RotatorService implements OnModuleInit {
|
|
6
|
+
private readonly dataSource;
|
|
7
|
+
private readonly databaseConfig;
|
|
8
|
+
private readonly schedulerRegistry;
|
|
9
|
+
private readonly logger;
|
|
10
|
+
constructor(dataSource: DataSource, databaseConfig: IDatabaseConfig, schedulerRegistry: SchedulerRegistry);
|
|
11
|
+
onModuleInit(): void;
|
|
12
|
+
rotateDatabaseConnection(): Promise<void>;
|
|
13
|
+
}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
+
};
|
|
11
|
+
var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
12
|
+
return function (target, key) { decorator(target, key, paramIndex); }
|
|
13
|
+
};
|
|
14
|
+
var RotatorService_1;
|
|
15
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
16
|
+
exports.RotatorService = void 0;
|
|
17
|
+
const common_1 = require("@nestjs/common");
|
|
18
|
+
const schedule_1 = require("@nestjs/schedule");
|
|
19
|
+
const typeorm_1 = require("typeorm");
|
|
20
|
+
const database_provider_1 = require("../../../shared/provider/database/database.provider");
|
|
21
|
+
let RotatorService = RotatorService_1 = class RotatorService {
|
|
22
|
+
constructor(dataSource, databaseConfig, schedulerRegistry) {
|
|
23
|
+
this.dataSource = dataSource;
|
|
24
|
+
this.databaseConfig = databaseConfig;
|
|
25
|
+
this.schedulerRegistry = schedulerRegistry;
|
|
26
|
+
this.logger = new common_1.Logger(RotatorService_1.name);
|
|
27
|
+
}
|
|
28
|
+
onModuleInit() {
|
|
29
|
+
if (this.databaseConfig.rotation?.isEnabled) {
|
|
30
|
+
const intervalMs = this.databaseConfig.rotation.intervalMs;
|
|
31
|
+
const interval = setInterval(() => {
|
|
32
|
+
this.rotateDatabaseConnection();
|
|
33
|
+
}, intervalMs);
|
|
34
|
+
this.schedulerRegistry.addInterval("db-rotation", interval);
|
|
35
|
+
this.logger.log(`DB credentials rotation interval started: ${intervalMs} ΠΌΡ`);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
async rotateDatabaseConnection() {
|
|
39
|
+
this.logger.log("Launching DB credentials rotation interval...");
|
|
40
|
+
const currentOptions = this.dataSource.options;
|
|
41
|
+
if (this.dataSource.isInitialized) {
|
|
42
|
+
await this.dataSource.destroy();
|
|
43
|
+
}
|
|
44
|
+
const newOptions = { ...currentOptions };
|
|
45
|
+
const newDataSource = new typeorm_1.DataSource(newOptions);
|
|
46
|
+
await newDataSource.initialize();
|
|
47
|
+
this.dataSource.subscribers.forEach((subscriber) => {
|
|
48
|
+
newDataSource.subscribers.push(subscriber);
|
|
49
|
+
});
|
|
50
|
+
this.dataSource.setOptions(newOptions);
|
|
51
|
+
this.dataSource.driver = newDataSource.driver;
|
|
52
|
+
this.logger.log("Rotation completed!");
|
|
53
|
+
}
|
|
54
|
+
};
|
|
55
|
+
exports.RotatorService = RotatorService;
|
|
56
|
+
exports.RotatorService = RotatorService = RotatorService_1 = __decorate([
|
|
57
|
+
(0, common_1.Injectable)(),
|
|
58
|
+
__param(1, (0, common_1.Inject)(database_provider_1.DATABASE_CONFIG_PROVIDER)),
|
|
59
|
+
__metadata("design:paramtypes", [typeorm_1.DataSource, Object, schedule_1.SchedulerRegistry])
|
|
60
|
+
], RotatorService);
|
|
61
|
+
//# sourceMappingURL=rotator.service.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rotator.service.js","sourceRoot":"","sources":["../../../../src/modules/database/rotator/rotator.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,2CAA0E;AAC1E,+CAAqD;AACrD,qCAAmF;AAEnF,2FAAuF;AAGhF,IAAM,cAAc,sBAApB,MAAM,cAAc;IAG1B,YACkB,UAAsB,EAEvC,cAAgD,EAC/B,iBAAoC;QAHpC,eAAU,GAAV,UAAU,CAAY;QAEtB,mBAAc,GAAd,cAAc,CAAiB;QAC/B,sBAAiB,GAAjB,iBAAiB,CAAmB;QANrC,WAAM,GAAG,IAAI,eAAM,CAAC,gBAAc,CAAC,IAAI,CAAC,CAAC;IAOvD,CAAC;IAEJ,YAAY;QACX,IAAI,I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CACD,CAAA;AA7CY,wCAAc;yBAAd,cAAc;IAD1B,IAAA,mBAAU,GAAE;IAMV,WAAA,IAAA,eAAM,EAAC,4CAAwB,CAAC,CAAA;qCADJ,oBAAU,UAGH,4BAAiB;GAP1C,cAAc,CA6C1B"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
declare const CONFIG_CONSTANT: {
|
|
2
|
+
readonly DATABASE_CONNECTION_ROTAION_INTERVAL: number;
|
|
3
|
+
readonly DB_CONNECTION_TIMEOUT: number;
|
|
4
|
+
readonly DB_DATABASE_NAME: string;
|
|
5
|
+
readonly DB_IDLE_TIMEOUT: number;
|
|
6
|
+
readonly DB_LOGGING: boolean;
|
|
7
|
+
readonly DB_POOL_SIZE: number;
|
|
8
|
+
readonly DB_PORT: number;
|
|
9
|
+
readonly DB_RECONNECT_TIMEOUT: number;
|
|
10
|
+
readonly DB_RELATION_LOAD_STRATEGY: "join" | "query" | undefined;
|
|
11
|
+
readonly DB_SYNCHRONIZE: boolean;
|
|
12
|
+
readonly DB_TYPE: "postgres";
|
|
13
|
+
readonly SWAGGER_SAVE_SPACES: number;
|
|
14
|
+
};
|
|
15
|
+
export default CONFIG_CONSTANT;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const SWAGGER_SAVE_SPACES = 2;
|
|
4
|
+
const DB_CONNECTION_TIMEOUT = 30_000;
|
|
5
|
+
const DB_IDLE_TIMEOUT = 30_000;
|
|
6
|
+
const DB_RECONNECT_TIMEOUT = 3000;
|
|
7
|
+
const DB_POOL_SIZE = 10;
|
|
8
|
+
const DB_PORT = 5432;
|
|
9
|
+
const DB_RELATION_LOAD_STRATEGY = "query";
|
|
10
|
+
const DB_SYNCHRONIZE = false;
|
|
11
|
+
const DB_TYPE = "postgres";
|
|
12
|
+
const DB_LOGGING = false;
|
|
13
|
+
const DB_DATABASE_NAME = "my_default_database";
|
|
14
|
+
const DATABASE_CONNECTION_ROTAION_INTERVAL = 1000 * 60 * 60; // 1 hour in milliseconds
|
|
15
|
+
const CONFIG_CONSTANT = {
|
|
16
|
+
DATABASE_CONNECTION_ROTAION_INTERVAL,
|
|
17
|
+
DB_CONNECTION_TIMEOUT,
|
|
18
|
+
DB_DATABASE_NAME,
|
|
19
|
+
DB_IDLE_TIMEOUT,
|
|
20
|
+
DB_LOGGING,
|
|
21
|
+
DB_POOL_SIZE,
|
|
22
|
+
DB_PORT,
|
|
23
|
+
DB_RECONNECT_TIMEOUT,
|
|
24
|
+
DB_RELATION_LOAD_STRATEGY,
|
|
25
|
+
DB_SYNCHRONIZE,
|
|
26
|
+
DB_TYPE,
|
|
27
|
+
SWAGGER_SAVE_SPACES,
|
|
28
|
+
};
|
|
29
|
+
exports.default = CONFIG_CONSTANT;
|
|
30
|
+
//# sourceMappingURL=constant.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constant.js","sourceRoot":"","sources":["../../../../src/shared/constant/database/constant.ts"],"names":[],"mappings":";;AAAA,MAAM,mBAAmB,GAAW,CAAC,CAAC;AACtC,MAAM,qBAAqB,GAAW,MAAM,CAAC;AAC7C,MAAM,eAAe,GAAW,MAAM,CAAC;AACvC,MAAM,oBAAoB,GAAW,IAAI,CAAC;AAC1C,MAAM,YAAY,GAAW,EAAE,CAAC;AAChC,MAAM,OAAO,GAAW,IAAI,CAAC;AAC7B,MAAM,yBAAyB,GAAiC,OAAO,CAAC;AACxE,MAAM,cAAc,GAAY,KAAK,CAAC;AACtC,MAAM,OAAO,GAAyB,UAAU,CAAC;AACjD,MAAM,UAAU,GAAY,KAAK,CAAC;AAClC,MAAM,gBAAgB,GAAW,qBAAqB,CAAC;AACvD,MAAM,oCAAoC,GAAW,IAAI,GAAG,EAAE,GAAG,EAAE,CAAC,CAAC,yBAAyB;AAE9F,MAAM,eAAe,GAajB;IACH,oCAAoC;IACpC,qBAAqB;IACrB,gBAAgB;IAChB,eAAe;IACf,UAAU;IACV,YAAY;IACZ,OAAO;IACP,oBAAoB;IACpB,yBAAyB;IACzB,cAAc;IACd,OAAO;IACP,mBAAmB;CACV,CAAC;AAEX,kBAAe,eAAe,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.EDatabaseType = void 0;
|
|
4
|
+
var EDatabaseType;
|
|
5
|
+
(function (EDatabaseType) {
|
|
6
|
+
EDatabaseType["MYSQL"] = "mysql";
|
|
7
|
+
EDatabaseType["POSTGRES"] = "postgres";
|
|
8
|
+
})(EDatabaseType || (exports.EDatabaseType = EDatabaseType = {}));
|
|
9
|
+
//# sourceMappingURL=type.enum.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"type.enum.js","sourceRoot":"","sources":["../../../../src/shared/enum/database/type.enum.ts"],"names":[],"mappings":";;;AAAA,IAAY,aAGX;AAHD,WAAY,aAAa;IACxB,gCAAe,CAAA;IACf,sCAAqB,CAAA;AACtB,CAAC,EAHW,aAAa,6BAAb,aAAa,QAGxB"}
|