@@ -60,23 +60,25 @@ export class WAMonitoringService {
6060 }
6161
6262 public async instanceInfo ( instanceNames ?: string [ ] ) : Promise < any > {
63- const inexistentInstances = instanceNames ? instanceNames . filter ( ( instance ) => ! this . waInstances [ instance ] ) : [ ] ;
63+ if ( instanceNames && instanceNames . length > 0 ) {
64+ const inexistentInstances = instanceNames ? instanceNames . filter ( ( instance ) => ! this . waInstances [ instance ] ) : [ ] ;
6465
65- if ( inexistentInstances . length > 0 ) {
66- throw new NotFoundException (
67- `Instance${ inexistentInstances . length > 1 ? 's' : '' } "${ inexistentInstances . join ( ', ' ) } " not found` ,
68- ) ;
66+ if ( inexistentInstances . length > 0 ) {
67+ throw new NotFoundException (
68+ `Instance${ inexistentInstances . length > 1 ? 's' : '' } "${ inexistentInstances . join ( ', ' ) } " not found` ,
69+ ) ;
70+ }
6971 }
7072
7173 const clientName = this . configService . get < Database > ( 'DATABASE' ) . CONNECTION . CLIENT_NAME ;
7274
73- const where = instanceNames
75+ const where = instanceNames && instanceNames . length > 0
7476 ? {
75- name : {
76- in : instanceNames ,
77- } ,
78- clientName,
79- }
77+ name : {
78+ in : instanceNames ,
79+ } ,
80+ clientName,
81+ }
8082 : { clientName } ;
8183
8284 const instances = await this . prismaRepository . instance . findMany ( {
@@ -123,7 +125,9 @@ export class WAMonitoringService {
123125 throw new NotFoundException ( `Instance "${ instanceName } " not found` ) ;
124126 }
125127
126- return this . instanceInfo ( [ instanceName ] ) ;
128+ const instanceNames = instanceName ? [ instanceName ] : null ;
129+
130+ return this . instanceInfo ( instanceNames ) ;
127131 }
128132
129133 public async cleaningUp ( instanceName : string ) {
0 commit comments