1
- import { Inject , Injectable , Logger } from ' @nestjs/common' ;
1
+ import { Inject , Injectable , Logger } from " @nestjs/common" ;
2
2
import {
3
3
Job ,
4
4
Runner ,
@@ -8,16 +8,16 @@ import {
8
8
makeWorkerUtils ,
9
9
run ,
10
10
runOnce ,
11
- } from ' graphile-worker' ;
12
- import { RUNNER_OPTIONS_KEY } from ' ../interfaces/module-config.interfaces' ;
13
- import { uniq } from ' ../utils/array.utils' ;
14
- import { ListenerExplorerService } from ' ./listener-explorer.service' ;
15
- import { TaskExplorerService } from ' ./task-explorer.service' ;
11
+ } from " graphile-worker" ;
12
+ import { RUNNER_OPTIONS_KEY } from " ../interfaces/module-config.interfaces" ;
13
+ import { uniq } from " ../utils/array.utils" ;
14
+ import { ListenerExplorerService } from " ./listener-explorer.service" ;
15
+ import { TaskExplorerService } from " ./task-explorer.service" ;
16
16
17
17
@Injectable ( )
18
18
export class WorkerService {
19
19
private readonly logger = new Logger ( WorkerService . name ) ;
20
- private isMigrationDone : boolean ;
20
+ private isMigrationDone = false ;
21
21
22
22
constructor (
23
23
@Inject ( RUNNER_OPTIONS_KEY ) private readonly options : RunnerOptions ,
@@ -36,7 +36,7 @@ export class WorkerService {
36
36
async run ( ) : Promise < Runner > {
37
37
await this . runMigrations ( ) ;
38
38
39
- this . logger . debug ( ' Start runner' ) ;
39
+ this . logger . debug ( " Start runner" ) ;
40
40
41
41
return await run ( this . options ) ;
42
42
}
@@ -47,7 +47,7 @@ export class WorkerService {
47
47
async runOnce ( ) : Promise < void > {
48
48
await this . runMigrations ( ) ;
49
49
50
- this . logger . debug ( ' Start runner' ) ;
50
+ this . logger . debug ( " Start runner" ) ;
51
51
52
52
await runOnce ( this . options ) ;
53
53
}
@@ -89,7 +89,7 @@ export class WorkerService {
89
89
return ;
90
90
}
91
91
92
- this . logger . debug ( ' Run migrations' ) ;
92
+ this . logger . debug ( " Run migrations" ) ;
93
93
this . isMigrationDone = true ;
94
94
}
95
95
@@ -99,6 +99,8 @@ export class WorkerService {
99
99
( { event } ) => event ,
100
100
) ;
101
101
102
+ if ( this . options . events === undefined ) return ;
103
+
102
104
for ( const event of uniq ( events ) ) {
103
105
this . options . events . on ( event , ( ...args : any [ ] ) => {
104
106
this . listenerExplorerService . listeners
0 commit comments