@@ -58,24 +58,27 @@ export class WAMonitoringService {
5858 }
5959
6060 public async instanceInfo ( instanceNames ?: string [ ] ) : Promise < any > {
61- const inexistentInstances = instanceNames ? instanceNames . filter ( ( instance ) => ! this . waInstances [ instance ] ) : [ ] ;
61+ if ( instanceNames && instanceNames . length > 0 ) {
62+ const inexistentInstances = instanceNames ? instanceNames . filter ( ( instance ) => ! this . waInstances [ instance ] ) : [ ] ;
6263
63- if ( inexistentInstances . length > 0 ) {
64- throw new NotFoundException (
65- `Instance${ inexistentInstances . length > 1 ? 's' : '' } "${ inexistentInstances . join ( ', ' ) } " not found` ,
66- ) ;
64+ if ( inexistentInstances . length > 0 ) {
65+ throw new NotFoundException (
66+ `Instance${ inexistentInstances . length > 1 ? 's' : '' } "${ inexistentInstances . join ( ', ' ) } " not found` ,
67+ ) ;
68+ }
6769 }
6870
6971 const clientName = this . configService . get < Database > ( 'DATABASE' ) . CONNECTION . CLIENT_NAME ;
7072
71- const where = instanceNames
72- ? {
73- name : {
74- in : instanceNames ,
75- } ,
76- clientName,
77- }
78- : { clientName } ;
73+ const where =
74+ instanceNames && instanceNames . length > 0
75+ ? {
76+ name : {
77+ in : instanceNames ,
78+ } ,
79+ clientName,
80+ }
81+ : { clientName } ;
7982
8083 const instances = await this . prismaRepository . instance . findMany ( {
8184 where,
@@ -121,7 +124,8 @@ export class WAMonitoringService {
121124 throw new NotFoundException ( `Instance "${ instanceName } " not found` ) ;
122125 }
123126
124- return this . instanceInfo ( [ instanceName ] ) ;
127+ const instanceNames = instanceName ? [ instanceName ] : null ;
128+ return this . instanceInfo ( instanceNames ) ;
125129 }
126130
127131 public async cleaningUp ( instanceName : string ) {
0 commit comments