1
- import { IntegrationEntity } from '@novu/dal' ;
2
- import { IntegrationRepository } from '@novu/dal' ;
1
+ import { IntegrationEntity , IntegrationRepository } from '@novu/dal' ;
3
2
import { ICredentialsDto , secureCredentials } from '@novu/shared' ;
4
3
import { encryptSecret } from '@novu/application-generic' ;
4
+ import { getLogger } from '../../src/app/shared/services/logger.service' ;
5
+
6
+ const logger = getLogger ( 'EncryptCredentialsMigration' ) ;
5
7
6
8
export async function encryptOldCredentialsMigration ( ) {
7
- // eslint-disable-next-line no-console
8
- console . log ( 'start migration - encrypt credentials' ) ;
9
+ logger . info ( 'start migration - encrypt credentials' ) ;
9
10
10
11
const integrationRepository = new IntegrationRepository ( ) ;
11
12
const integrations = await integrationRepository . find ( { } as any ) ;
12
13
13
14
for ( const integration of integrations ) {
14
- // eslint-disable-next-line no-console
15
- console . log ( `integration ${ integration . _id } ` ) ;
15
+ logger . info ( `integration ${ integration . _id } ` ) ;
16
16
17
17
const updatePayload : Partial < IntegrationEntity > = { } ;
18
18
19
19
if ( ! integration . credentials ) {
20
- // eslint-disable-next-line no-console
21
- console . log ( `integration ${ integration . _id } - is not contains credentials, skipping..` ) ;
20
+ logger . info ( `integration ${ integration . _id } - is not contains credentials, skipping..` ) ;
22
21
continue ;
23
22
}
24
23
@@ -30,16 +29,14 @@ export async function encryptOldCredentialsMigration() {
30
29
$set : updatePayload ,
31
30
}
32
31
) ;
33
- // eslint-disable-next-line no-console
34
- console . log ( `integration ${ integration . _id } - credentials updated` ) ;
32
+ logger . info ( `integration ${ integration . _id } - credentials updated` ) ;
35
33
}
36
- // eslint-disable-next-line no-console
37
- console . log ( 'end migration' ) ;
34
+ logger . info ( 'end migration' ) ;
38
35
}
39
36
40
37
export function encryptCredentialsWithGuard ( integration : IntegrationEntity ) : ICredentialsDto {
41
38
const encryptedCredentials : ICredentialsDto = { } ;
42
- const credentials = integration . credentials ;
39
+ const { credentials } = integration ;
43
40
44
41
for ( const key in credentials ) {
45
42
const credential = credentials [ key ] ;
@@ -66,8 +63,7 @@ function alreadyEncrypted(credential: string, integration: IntegrationEntity, cr
66
63
const encrypted = credential . includes ( 'nvsk.' ) ;
67
64
68
65
if ( encrypted ) {
69
- // eslint-disable-next-line no-console
70
- console . log ( `integration ${ integration . _id } - credential ${ credentialKey } is already updated` ) ;
66
+ logger . info ( `integration ${ integration . _id } - credential ${ credentialKey } is already updated` ) ;
71
67
}
72
68
73
69
return encrypted ;
0 commit comments