@aldb2b/common 1.0.575 → 1.0.576
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/build/entities/models/common/common.provider.d.ts +7 -2
- package/build/entities/models/common/common.provider.js +5 -1
- package/build/entities/models/common/common.provider.js.map +1 -1
- package/build/entities/models/common/entities/audit-trail.entity.d.ts +3 -0
- package/build/entities/models/common/entities/audit-trail.entity.js +17 -0
- package/build/entities/models/common/entities/audit-trail.entity.js.map +1 -1
- package/build/entities/models/common/entities/audit-trail.repository.js.map +1 -1
- package/build/entities/models/common/services/audit-trail.service.d.ts +8 -4
- package/build/entities/models/common/services/audit-trail.service.js +44 -16
- package/build/entities/models/common/services/audit-trail.service.js.map +1 -1
- package/build/entities/models/model.providers.d.ts +6 -2
- package/build/entities/mongoose.providers.d.ts +2 -2
- package/build/entities/mongoose.providers.js +14 -25
- package/build/entities/mongoose.providers.js.map +1 -1
- package/build/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
|
@@ -58,18 +58,23 @@ import { User } from '../users';
|
|
|
58
58
|
import { AuditTrail } from './entities/audit-trail.entity';
|
|
59
59
|
import { AuditTrailRepository } from './entities/audit-trail.repository';
|
|
60
60
|
import { AuditTrailService } from './services/audit-trail.service';
|
|
61
|
+
import { Scope } from '@nestjs/common';
|
|
62
|
+
import { Request } from 'express';
|
|
61
63
|
export declare const commonProviders: ({
|
|
62
64
|
provide: DatabaseModel;
|
|
63
65
|
useFactory: (connection: import("mongoose").Connection, eventConnection: import("mongoose").Connection, userConnection: import("mongoose").Connection) => import("mongoose").Model<AuditTrail, {}, {}, {}, import("mongoose").Document<unknown, {}, AuditTrail> & AuditTrail & Required<{
|
|
64
66
|
_id: string;
|
|
65
67
|
}>, any>;
|
|
66
68
|
inject: DatabaseConnection[];
|
|
69
|
+
scope?: undefined;
|
|
67
70
|
} | {
|
|
68
71
|
provide: RepositoryProvide;
|
|
69
72
|
inject: DatabaseModel[];
|
|
70
73
|
useFactory: (auditModel: CustomModel<AuditTrail>) => AuditTrailRepository;
|
|
74
|
+
scope?: undefined;
|
|
71
75
|
} | {
|
|
72
76
|
provide: ServiceProvide;
|
|
73
|
-
|
|
74
|
-
|
|
77
|
+
scope: Scope;
|
|
78
|
+
inject: string[];
|
|
79
|
+
useFactory: (req: Request, auditLogRepository: AuditTrailRepository, userModel: CustomModel<User>) => AuditTrailService;
|
|
75
80
|
})[];
|
|
@@ -8,6 +8,8 @@ const service_provide_enum_1 = require("../../../enums/service-provide.enum");
|
|
|
8
8
|
const audit_trail_entity_1 = require("./entities/audit-trail.entity");
|
|
9
9
|
const audit_trail_repository_1 = require("./entities/audit-trail.repository");
|
|
10
10
|
const audit_trail_service_1 = require("./services/audit-trail.service");
|
|
11
|
+
const common_1 = require("@nestjs/common");
|
|
12
|
+
const core_1 = require("@nestjs/core");
|
|
11
13
|
exports.commonProviders = [
|
|
12
14
|
{
|
|
13
15
|
provide: database_model_enum_1.DatabaseModel.AUDIT_TRAIL_MODEL,
|
|
@@ -25,11 +27,13 @@ exports.commonProviders = [
|
|
|
25
27
|
},
|
|
26
28
|
{
|
|
27
29
|
provide: service_provide_enum_1.ServiceProvide.AUDIT_TRAIL_SERVICE,
|
|
30
|
+
scope: common_1.Scope.REQUEST,
|
|
28
31
|
inject: [
|
|
29
32
|
repository_provide_enum_1.RepositoryProvide.AUDIT_TRAIL_REPOSITORY,
|
|
30
33
|
database_model_enum_1.DatabaseModel.USER_MODEL,
|
|
34
|
+
core_1.REQUEST,
|
|
31
35
|
],
|
|
32
|
-
useFactory: (auditLogRepository, userModel) => new audit_trail_service_1.AuditTrailService(auditLogRepository, userModel),
|
|
36
|
+
useFactory: (req, auditLogRepository, userModel) => new audit_trail_service_1.AuditTrailService(req, auditLogRepository, userModel),
|
|
33
37
|
},
|
|
34
38
|
];
|
|
35
39
|
//# sourceMappingURL=common.provider.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"common.provider.js","sourceRoot":"","sources":["../../../../src/entities/models/common/common.provider.ts"],"names":[],"mappings":";;;AAAA,4EAAkE;AAClE,sFAA4E;AAC5E,oFAA0E;AAE1E,8EAAoE;AAEpE,sEAA6E;AAC7E,8EAAwE;AACxE,wEAAkE;
|
|
1
|
+
{"version":3,"file":"common.provider.js","sourceRoot":"","sources":["../../../../src/entities/models/common/common.provider.ts"],"names":[],"mappings":";;;AAAA,4EAAkE;AAClE,sFAA4E;AAC5E,oFAA0E;AAE1E,8EAAoE;AAEpE,sEAA6E;AAC7E,8EAAwE;AACxE,wEAAkE;AAClE,2CAAsC;AACtC,uCAAsC;AAGzB,QAAA,eAAe,GAAG;IAC7B;QACE,OAAO,EAAE,mCAAa,CAAC,iBAAiB;QACxC,UAAU,EAAE,sCAAiB;QAC7B,MAAM,EAAE;YACN,6CAAkB,CAAC,kBAAkB;YACrC,6CAAkB,CAAC,gBAAgB;YACnC,6CAAkB,CAAC,eAAe;SACnC;KACF;IACD;QACE,OAAO,EAAE,2CAAiB,CAAC,sBAAsB;QACjD,MAAM,EAAE,CAAC,mCAAa,CAAC,iBAAiB,CAAC;QACzC,UAAU,EAAE,CAAC,UAAmC,EAAE,EAAE,CAClD,IAAI,6CAAoB,CAAC,UAAU,CAAC;KACvC;IACD;QACE,OAAO,EAAE,qCAAc,CAAC,mBAAmB;QAC3C,KAAK,EAAE,cAAK,CAAC,OAAO;QACpB,MAAM,EAAE;YACN,2CAAiB,CAAC,sBAAsB;YACxC,mCAAa,CAAC,UAAU;YACxB,cAAO;SACR;QACD,UAAU,EAAE,CACV,GAAY,EACZ,kBAAwC,EACxC,SAA4B,EAC5B,EAAE,CAAC,IAAI,uCAAiB,CAAC,GAAG,EAAE,kBAAkB,EAAE,SAAS,CAAC;KAC/D;CACF,CAAA"}
|
|
@@ -51,6 +51,17 @@ const auditTrailFactory = (connection, eventConnection, userConnection) => {
|
|
|
51
51
|
type: Mixed,
|
|
52
52
|
required: true,
|
|
53
53
|
},
|
|
54
|
+
auditMethod: {
|
|
55
|
+
type: String,
|
|
56
|
+
trim: true,
|
|
57
|
+
},
|
|
58
|
+
auditRoute: {
|
|
59
|
+
type: String,
|
|
60
|
+
trim: true,
|
|
61
|
+
},
|
|
62
|
+
auditPayload: {
|
|
63
|
+
type: Mixed,
|
|
64
|
+
},
|
|
54
65
|
performedAt: { type: Date, required: true, default: Date.now },
|
|
55
66
|
});
|
|
56
67
|
const allProjectionFieldArray = [
|
|
@@ -64,6 +75,9 @@ const auditTrailFactory = (connection, eventConnection, userConnection) => {
|
|
|
64
75
|
'identifier',
|
|
65
76
|
'module',
|
|
66
77
|
'auditInfo',
|
|
78
|
+
'auditMethod',
|
|
79
|
+
'auditRoute',
|
|
80
|
+
'auditPayload',
|
|
67
81
|
'performedAt',
|
|
68
82
|
];
|
|
69
83
|
const allValidateNewItemFieldArray = [
|
|
@@ -77,6 +91,9 @@ const auditTrailFactory = (connection, eventConnection, userConnection) => {
|
|
|
77
91
|
'identifier',
|
|
78
92
|
'module',
|
|
79
93
|
'auditInfo',
|
|
94
|
+
'auditMethod',
|
|
95
|
+
'auditRoute',
|
|
96
|
+
'auditPayload',
|
|
80
97
|
'performedAt',
|
|
81
98
|
];
|
|
82
99
|
auditTrailSchema.statics.validateProjectionResult = necessaryProjectionObj => (0, validateProjectionResult_1.validateProjectionResult)(allProjectionFieldArray, necessaryProjectionObj);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"audit-trail.entity.js","sourceRoot":"","sources":["../../../../../src/entities/models/common/entities/audit-trail.entity.ts"],"names":[],"mappings":";;;AAAA,uCAA6C;AAG7C,4EAAwE;AACxE,kFAA8E;AAC9E,8FAA0F;AAE1F,mEAA6D;AAE7D,MAAM,QAAQ,GAAG,iBAAM,CAAC,KAAK,CAAC,QAAQ,CAAA;AACtC,MAAM,KAAK,GAAG,iBAAM,CAAC,KAAK,CAAC,KAAK,CAAA;AAEhC,MAAa,UAAU;
|
|
1
|
+
{"version":3,"file":"audit-trail.entity.js","sourceRoot":"","sources":["../../../../../src/entities/models/common/entities/audit-trail.entity.ts"],"names":[],"mappings":";;;AAAA,uCAA6C;AAG7C,4EAAwE;AACxE,kFAA8E;AAC9E,8FAA0F;AAE1F,mEAA6D;AAE7D,MAAM,QAAQ,GAAG,iBAAM,CAAC,KAAK,CAAC,QAAQ,CAAA;AACtC,MAAM,KAAK,GAAG,iBAAM,CAAC,KAAK,CAAC,KAAK,CAAA;AAEhC,MAAa,UAAU;CAetB;AAfD,gCAeC;AAGM,MAAM,iBAAiB,GAAG,CAC/B,UAAsB,EACtB,eAA2B,EAC3B,cAA0B,EAC1B,EAAE;IACF,MAAM,gBAAgB,GAAG,IAAI,iBAAM,CAA8B;QAC/D,OAAO,EAAE;YACP,IAAI,EAAE,QAAQ;YACd,GAAG,EAAE,IAAA,2BAAW,EAAC,OAAO,EAAE,eAAe,CAAC;SAC3C;QACD,KAAK,EAAE;YACL,IAAI,EAAE,MAAM;YACZ,IAAI,EAAE,IAAI;SACX;QACD,YAAY,EAAE;YACZ,IAAI,EAAE,OAAO;YACb,OAAO,EAAE,KAAK;SACf;QACD,WAAW,EAAE;YACX,IAAI,EAAE,QAAQ;YACd,GAAG,EAAE,IAAA,2BAAW,EAAC,MAAM,EAAE,cAAc,CAAC;SACzC;QACD,eAAe,EAAE;YACf,IAAI,EAAE,MAAM;YACZ,IAAI,EAAE,IAAI;SACX;QACD,SAAS,EAAE;YACT,IAAI,EAAE,MAAM;YACZ,IAAI,EAAE,IAAI;SACX;QACD,UAAU,EAAE;YACV,IAAI,EAAE,MAAM;YACZ,IAAI,EAAE,IAAI;YACV,QAAQ,EAAE,IAAI;SACf;QACD,MAAM,EAAE;YACN,IAAI,EAAE,MAAM;YACZ,IAAI,EAAE,IAAI;YACV,QAAQ,EAAE,IAAI;SACf;QACD,SAAS,EAAE;YACT,IAAI,EAAE,KAAK;YACX,QAAQ,EAAE,IAAI;SACf;QACD,WAAW,EAAE;YACX,IAAI,EAAE,MAAM;YACZ,I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
|
1
|
-
{"version":3,"file":"audit-trail.repository.js","sourceRoot":"","sources":["../../../../../src/entities/models/common/entities/audit-trail.repository.ts"],"names":[],"mappings":";;;AAEA,8DAA0D;
|
|
1
|
+
{"version":3,"file":"audit-trail.repository.js","sourceRoot":"","sources":["../../../../../src/entities/models/common/entities/audit-trail.repository.ts"],"names":[],"mappings":";;;AAEA,8DAA0D;AAE1D,MAAa,oBAAqB,SAAQ,2BAAwB;IAChE,YAAoB,eAAwC;QAC1D,KAAK,CAAC,eAAe,CAAC,CAAA;QADJ,oBAAe,GAAf,eAAe,CAAyB;IAE5D,CAAC;CACF;AAJD,oDAIC"}
|
|
@@ -4,19 +4,23 @@ import { AuditTrail } from '../entities/audit-trail.entity';
|
|
|
4
4
|
import { AuditTrailRepository } from '../entities/audit-trail.repository';
|
|
5
5
|
import { FindAuditTrailDto } from '../dto/find-audit-trail.dto';
|
|
6
6
|
import { ReadResult } from '../../../../types/read-result.interface';
|
|
7
|
-
import { HeaderUser } from '../../../../types/header-user.interface';
|
|
8
7
|
import { ActionEnum } from '../../../../db/auditTrail/interfaces/Action.enum';
|
|
8
|
+
import { Request } from 'express';
|
|
9
9
|
export declare class AuditTrailService {
|
|
10
|
+
private readonly req;
|
|
10
11
|
private readonly auditTrailRepository;
|
|
11
12
|
private readonly userModel;
|
|
12
|
-
headerData?: HeaderUser;
|
|
13
13
|
userData?: User;
|
|
14
|
-
constructor(auditTrailRepository: AuditTrailRepository, userModel: CustomModel<User>);
|
|
14
|
+
constructor(req: Request, auditTrailRepository: AuditTrailRepository, userModel: CustomModel<User>);
|
|
15
15
|
getAuditTrails(findAuditTrailDto: FindAuditTrailDto): Promise<ReadResult<AuditTrail>>;
|
|
16
16
|
getAuditTrailById(id: string): Promise<AuditTrail>;
|
|
17
|
-
create(identifier: string, module: string, auditInfo: any, auditType: ActionEnum,
|
|
17
|
+
create(identifier: string, module: string, auditInfo: any, auditType: ActionEnum, notes?: string, userId?: string, enrichByTool?: boolean): Promise<void>;
|
|
18
18
|
private getRequestDetails;
|
|
19
19
|
private getRequesterData;
|
|
20
|
+
get eventId(): string;
|
|
21
|
+
get auditMethod(): string;
|
|
22
|
+
get auditRoute(): string;
|
|
23
|
+
get auditPayload(): any;
|
|
20
24
|
get performedBy(): string;
|
|
21
25
|
get performedByName(): string;
|
|
22
26
|
private difference;
|
|
@@ -3,8 +3,10 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.AuditTrailService = void 0;
|
|
4
4
|
const lodash_1 = require("lodash");
|
|
5
5
|
const get_parsed_query_1 = require("../../../../utils/get-parsed-query");
|
|
6
|
+
const getHeaderParam_1 = require("../../../../utils/getHeaderParam");
|
|
6
7
|
class AuditTrailService {
|
|
7
|
-
constructor(auditTrailRepository, userModel) {
|
|
8
|
+
constructor(req, auditTrailRepository, userModel) {
|
|
9
|
+
this.req = req;
|
|
8
10
|
this.auditTrailRepository = auditTrailRepository;
|
|
9
11
|
this.userModel = userModel;
|
|
10
12
|
this.difference = (origObj, newObj) => {
|
|
@@ -39,30 +41,34 @@ class AuditTrailService {
|
|
|
39
41
|
async getAuditTrailById(id) {
|
|
40
42
|
return await this.auditTrailRepository.findOne({ _id: id }, {}, []);
|
|
41
43
|
}
|
|
42
|
-
async create(identifier, module, auditInfo, auditType,
|
|
44
|
+
async create(identifier, module, auditInfo, auditType, notes, userId, enrichByTool = false) {
|
|
43
45
|
try {
|
|
44
|
-
this.headerData = user;
|
|
45
46
|
const { performedBy, performedByName } = await this.getRequestDetails(userId);
|
|
46
|
-
const
|
|
47
|
+
const trailToCreate = {
|
|
47
48
|
performedBy: performedBy,
|
|
48
49
|
performedByName: performedByName,
|
|
49
50
|
identifier: identifier,
|
|
50
51
|
enrichByTool: enrichByTool,
|
|
51
52
|
module: module,
|
|
52
|
-
eventId: eventId,
|
|
53
|
+
eventId: this.eventId,
|
|
53
54
|
auditType: auditType,
|
|
55
|
+
auditMethod: this.auditMethod,
|
|
56
|
+
auditRoute: this.auditRoute,
|
|
57
|
+
auditPayload: this.auditPayload,
|
|
54
58
|
notes: notes,
|
|
55
59
|
};
|
|
56
60
|
if (auditInfo && auditInfo.old && auditInfo.new) {
|
|
57
61
|
const newRec = this.difference(auditInfo.old, auditInfo.new);
|
|
58
62
|
auditInfo.new = newRec;
|
|
59
63
|
auditInfo.old = auditInfo.old;
|
|
64
|
+
trailToCreate.auditInfo = auditInfo;
|
|
60
65
|
if (Object.keys(newRec).length) {
|
|
61
|
-
await this.auditTrailRepository.create(
|
|
66
|
+
await this.auditTrailRepository.create(trailToCreate);
|
|
62
67
|
}
|
|
63
68
|
}
|
|
64
69
|
else {
|
|
65
|
-
|
|
70
|
+
trailToCreate.auditInfo = auditInfo;
|
|
71
|
+
await this.auditTrailRepository.create(trailToCreate);
|
|
66
72
|
}
|
|
67
73
|
}
|
|
68
74
|
catch (error) {
|
|
@@ -77,7 +83,7 @@ class AuditTrailService {
|
|
|
77
83
|
};
|
|
78
84
|
}
|
|
79
85
|
async getRequesterData(userId) {
|
|
80
|
-
if (
|
|
86
|
+
if (this.userModel && userId) {
|
|
81
87
|
this.userData = await this.userModel.findById(userId, {
|
|
82
88
|
_id: 1,
|
|
83
89
|
firstname: 1,
|
|
@@ -86,24 +92,46 @@ class AuditTrailService {
|
|
|
86
92
|
}, { lean: true });
|
|
87
93
|
}
|
|
88
94
|
}
|
|
95
|
+
get eventId() {
|
|
96
|
+
if (this.req && this.req.headers) {
|
|
97
|
+
return (0, getHeaderParam_1.getHeaderParam)(this.req.headers, 'event-id');
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
get auditMethod() {
|
|
101
|
+
if (this.req && this.req.method) {
|
|
102
|
+
return this.req.method;
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
get auditRoute() {
|
|
106
|
+
if (this.req && this.req.originalUrl) {
|
|
107
|
+
return this.req.originalUrl;
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
get auditPayload() {
|
|
111
|
+
return {
|
|
112
|
+
body: this.req.body,
|
|
113
|
+
query: this.req.query,
|
|
114
|
+
params: this.req.params,
|
|
115
|
+
};
|
|
116
|
+
}
|
|
89
117
|
get performedBy() {
|
|
90
118
|
let id = '';
|
|
91
|
-
if (this.
|
|
92
|
-
id = this.headerData.id;
|
|
93
|
-
}
|
|
94
|
-
else if (this.userData) {
|
|
119
|
+
if (this.userData) {
|
|
95
120
|
id = this.userData._id;
|
|
96
121
|
}
|
|
122
|
+
else if (this.req && this.req.headers) {
|
|
123
|
+
id = (0, getHeaderParam_1.getHeaderParam)(this.req.headers, 'id');
|
|
124
|
+
}
|
|
97
125
|
return id;
|
|
98
126
|
}
|
|
99
127
|
get performedByName() {
|
|
100
128
|
let fullname = '';
|
|
101
|
-
if (this.
|
|
102
|
-
fullname = `${this.headerData.firstname} ${this.headerData.lastname}`;
|
|
103
|
-
}
|
|
104
|
-
else if (this.userData) {
|
|
129
|
+
if (this.userData) {
|
|
105
130
|
fullname = `${this.userData.firstname} ${this.userData.lastname}`;
|
|
106
131
|
}
|
|
132
|
+
else if (this.req && this.req.headers) {
|
|
133
|
+
fullname = `${(0, getHeaderParam_1.getHeaderParam)(this.req.headers, 'firstname')} ${(0, getHeaderParam_1.getHeaderParam)(this.req.headers, 'lastname')}`;
|
|
134
|
+
}
|
|
107
135
|
return fullname;
|
|
108
136
|
}
|
|
109
137
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"audit-trail.service.js","sourceRoot":"","sources":["../../../../../src/entities/models/common/services/audit-trail.service.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"audit-trail.service.js","sourceRoot":"","sources":["../../../../../src/entities/models/common/services/audit-trail.service.ts"],"names":[],"mappings":";;;AAAA,mCAQe;AAOf,yEAAmE;AAEnE,qEAAiE;AAGjE,MAAa,iBAAiB;IAE5B,YACmB,GAAY,EACZ,oBAA0C,EAC1C,SAA4B;QAF5B,QAAG,GAAH,GAAG,CAAS;QACZ,yBAAoB,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CAkKC"}
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
/// <reference types="qs" />
|
|
2
|
+
/// <reference types="express" />
|
|
1
3
|
/// <reference types="mongoose/types/aggregate" />
|
|
2
4
|
/// <reference types="mongoose/types/callback" />
|
|
3
5
|
/// <reference types="mongoose/types/collection" />
|
|
@@ -57,8 +59,10 @@ export declare const modelProviders: ({
|
|
|
57
59
|
provide: import("../..").RepositoryProvide;
|
|
58
60
|
inject: import("../..").DatabaseModel[];
|
|
59
61
|
useFactory: (auditModel: import("../..").CustomModel<import("./common").AuditTrail>) => import("./common").AuditTrailRepository;
|
|
62
|
+
scope?: undefined;
|
|
60
63
|
} | {
|
|
61
64
|
provide: import("../..").ServiceProvide;
|
|
62
|
-
|
|
63
|
-
|
|
65
|
+
scope: import("@nestjs/common").Scope;
|
|
66
|
+
inject: string[];
|
|
67
|
+
useFactory: (req: import("express").Request<import("express-serve-static-core").ParamsDictionary, any, any, import("qs").ParsedQs, Record<string, any>>, auditLogRepository: import("./common").AuditTrailRepository, userModel: import("../..").CustomModel<import("./users").User>) => import("./common").AuditTrailService;
|
|
64
68
|
})[];
|
|
@@ -48,9 +48,9 @@
|
|
|
48
48
|
/// <reference types="mongoose/types/inferschematype" />
|
|
49
49
|
/// <reference types="mongoose/types/inferrawdoctype" />
|
|
50
50
|
/// <reference types="@aldb2b/common/node_modules/mongoose/types/inferschematype" />
|
|
51
|
-
import
|
|
51
|
+
import { Connection } from 'mongoose';
|
|
52
52
|
import { DatabaseConnection } from '../enums/database-connection.enum';
|
|
53
53
|
export declare const mongooseProviders: {
|
|
54
54
|
provide: DatabaseConnection;
|
|
55
|
-
useFactory: () => Promise<
|
|
55
|
+
useFactory: () => Promise<Connection>;
|
|
56
56
|
}[];
|
|
@@ -1,52 +1,41 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.mongooseProviders = void 0;
|
|
4
|
-
const
|
|
4
|
+
const mongoose_1 = require("mongoose");
|
|
5
5
|
const database_connection_enum_1 = require("../enums/database-connection.enum");
|
|
6
6
|
exports.mongooseProviders = [
|
|
7
7
|
{
|
|
8
8
|
provide: database_connection_enum_1.DatabaseConnection.CURRENT_CONNECTION,
|
|
9
9
|
useFactory: async () => {
|
|
10
|
-
return await
|
|
11
|
-
const connection = mongoose.createConnection(process.env.MONGO_URI);
|
|
12
|
-
connection.on('connected', function () {
|
|
13
|
-
resolve(connection);
|
|
14
|
-
});
|
|
15
|
-
});
|
|
10
|
+
return await generateConnection(process.env.MONGO_URI);
|
|
16
11
|
},
|
|
17
12
|
},
|
|
18
13
|
{
|
|
19
14
|
provide: database_connection_enum_1.DatabaseConnection.EVENT_CONNECTION,
|
|
20
15
|
useFactory: async () => {
|
|
21
|
-
return await
|
|
22
|
-
const connection = mongoose.createConnection(process.env.MONGO_URI_EVENT);
|
|
23
|
-
connection.on('connected', function () {
|
|
24
|
-
resolve(connection);
|
|
25
|
-
});
|
|
26
|
-
});
|
|
16
|
+
return await generateConnection(process.env.MONGO_URI_EVENT);
|
|
27
17
|
},
|
|
28
18
|
},
|
|
29
19
|
{
|
|
30
20
|
provide: database_connection_enum_1.DatabaseConnection.USER_CONNECTION,
|
|
31
21
|
useFactory: async () => {
|
|
32
|
-
return await
|
|
33
|
-
const connection = mongoose.createConnection(process.env.MONGO_URI_USER);
|
|
34
|
-
connection.on('connected', function () {
|
|
35
|
-
resolve(connection);
|
|
36
|
-
});
|
|
37
|
-
});
|
|
22
|
+
return await generateConnection(process.env.MONGO_URI_USER);
|
|
38
23
|
},
|
|
39
24
|
},
|
|
40
25
|
{
|
|
41
26
|
provide: database_connection_enum_1.DatabaseConnection.COMPANY_CONNECTION,
|
|
42
27
|
useFactory: async () => {
|
|
43
|
-
return await
|
|
44
|
-
const connection = mongoose.createConnection(process.env.MONGO_URI_COMPANY);
|
|
45
|
-
connection.on('connected', function () {
|
|
46
|
-
resolve(connection);
|
|
47
|
-
});
|
|
48
|
-
});
|
|
28
|
+
return await generateConnection(process.env.MONGO_URI_COMPANY);
|
|
49
29
|
},
|
|
50
30
|
},
|
|
51
31
|
];
|
|
32
|
+
const generateConnection = async (uri) => {
|
|
33
|
+
return await new Promise((resolve, reject) => {
|
|
34
|
+
const connection = (0, mongoose_1.createConnection)(uri);
|
|
35
|
+
connection.on('connected', function () {
|
|
36
|
+
connection.set('overwriteModels', true);
|
|
37
|
+
resolve(connection);
|
|
38
|
+
});
|
|
39
|
+
});
|
|
40
|
+
};
|
|
52
41
|
//# sourceMappingURL=mongoose.providers.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mongoose.providers.js","sourceRoot":"","sources":["../../src/entities/mongoose.providers.ts"],"names":[],"mappings":";;;AAAA,
|
|
1
|
+
{"version":3,"file":"mongoose.providers.js","sourceRoot":"","sources":["../../src/entities/mongoose.providers.ts"],"names":[],"mappings":";;;AAAA,uCAAuD;AACvD,gFAAsE;AAEzD,QAAA,iBAAiB,GAAG;IAC/B;QACE,OAAO,EAAE,6CAAkB,CAAC,kBAAkB;QAC9C,UAAU,EAAE,KAAK,IAAyB,EAAE;YAC1C,OAAO,MAAM,kBAAkB,CAAC,OAAO,CAAC,GAAG,CAAC,SAAS,CAAC,CAAA;QACxD,CAAC;KACF;IACD;QACE,OAAO,EAAE,6CAAkB,CAAC,gBAAgB;QAC5C,UAAU,EAAE,KAAK,IAAyB,EAAE;YAC1C,OAAO,MAAM,kBAAkB,CAAC,OAAO,CAAC,GAAG,CAAC,eAAe,CAAC,CAAA;QAC9D,CAAC;KACF;IACD;QACE,OAAO,EAAE,6CAAkB,CAAC,eAAe;QAC3C,UAAU,EAAE,KAAK,IAAyB,EAAE;YAC1C,OAAO,MAAM,kBAAkB,CAAC,OAAO,CAAC,GAAG,CAAC,cAAc,CAAC,CAAA;QAC7D,CAAC;KACF;IACD;QACE,OAAO,EAAE,6CAAkB,CAAC,kBAAkB;QAC9C,UAAU,EAAE,KAAK,IAAyB,EAA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