@@ -70,7 +70,7 @@ ipcMain.on('connect', async (message: Electron.IpcMainEvent, username: string, i
70
70
console . log ( 'Connected to user provided MongoDB database' )
71
71
message . sender . send ( 'databaseConnected' , true ) ;
72
72
} else {
73
- console . log ( 'Failed to connect to databse ' )
73
+ console . log ( 'Failed to connect to database ' )
74
74
message . sender . send ( 'databaseConnected' , false ) ;
75
75
}
76
76
} )
@@ -85,43 +85,6 @@ ipcMain.on('connect', async (message: Electron.IpcMainEvent, username: string, i
85
85
message . sender . send ( 'databaseConnected' , false ) ;
86
86
}
87
87
}
88
-
89
-
90
-
91
- // try{
92
- // // set database type from parameter
93
- // currentDatabaseType = databaseType;
94
- // console.log('Database type: ', databaseType);
95
- // if(currentDatabaseType === 'MongoDB'){
96
- // // First check if there is already an established mongoose connection with another databse...
97
- // // const isConnected = mongoose.connection.readyState === 1;
98
- // // if (isConnected){
99
- // // console.log('A connection to a mongoDB has already been established. Closing connection.');
100
- // mongoose.connection.close((error) => {
101
- // if(error) {
102
- // console.log('Error closing mongoDB connection: ', error);
103
- // }
104
- // });
105
- // // }
106
- // console.log('Database connection not found. Establishing connection...');
107
- // // Connect to the proper database
108
- // mongoose.connect(URI, { useNewUrlParser: true, useUnifiedTopology: true })
109
- // .then(() => {
110
- // console.log('Connected to user provided mongo database!');
111
- // message.sender.send('databaseConnected', true);
112
- // })
113
- // .catch(error => {
114
- // console.log('Error connecting to MongoDB inside data.ts connection:', error);
115
- // });
116
- // } else if (currentDatabaseType === 'SQL'){
117
- // // has not been reconfigured to handle different requests to SQL databses.
118
- // pool = await connectPostgres(index, URI);
119
- // message.sender.send('databaseConnected', true);
120
- // }
121
- // } catch(err){
122
- // message.sender.send('databaseConnected', false);
123
- // console.log('Error connecting to databse: ', err);
124
- // }
125
88
} ) ;
126
89
127
90
/**
@@ -202,17 +165,22 @@ ipcMain.on('healthRequest', async (message: Electron.IpcMainEvent, service: stri
202
165
203
166
// SQL Database
204
167
if ( currentDatabaseType === 'SQL' ) {
168
+ console . log ( 'inside healthRequest call' )
205
169
// Get last 50 documents. If less than 50 get all
206
170
result = await postgresFetch ( service , pool ) ;
171
+ // const query = `SELECT * FROM services`;
172
+ // result = await pool.query(query);
173
+ // result = result.rows;
207
174
}
208
-
175
+ console . log ( 'result' , result )
209
176
// Async event emitter - send response'
210
177
211
178
message . sender . send ( 'healthResponse' , JSON . stringify ( result ) ) ;
212
179
} catch ( error ) {
213
180
// Catch errors
214
- console . log ( 'Error in "healthRequest" event' , message ) ;
215
- message . sender . send ( 'healthResponse' , { } ) ;
181
+ console . log ( 'error sending result to healthresponse in healthrequest' )
182
+ // console.log(' event', message);
183
+ // message.sender.send('healthResponse', {});
216
184
}
217
185
} ) ;
218
186
0 commit comments