@@ -20,6 +20,19 @@ const log = require('electron-log');
2020const mongoose = require ( 'mongoose' ) ;
2121const User = require ( '../models/UserModel' )
2222
23+ // const testURL = 'mongodb+srv://seconddbtest:seconddbtest@cluster0.yhztme0.mongodb.net/?retryWrites=true&w=majority';
24+ // const connectMongoose = async (i: number, URI: string) => {
25+ // try {
26+ // const db2 = mongoose.createConnection(testURL);
27+ // console.log('connection to user provided db established..');
28+ // return db2;
29+ // } catch (error) {
30+ // console.log('Error connecting to second db... ', error);
31+ // }
32+ // }
33+
34+
35+
2336const mongoFetch = fetchData . mongoFetch ;
2437const postgresFetch = fetchData . postgresFetch ;
2538const AWS = require ( 'aws-sdk' ) ;
@@ -57,17 +70,23 @@ ipcMain.on('connect', async (message: Electron.IpcMainEvent, username: string, i
5770 // useNewUrlParser: true,
5871 // useUnifiedtopology: true,
5972 // })
60-
73+ // test().catch((error) => console.log('error in second db', error));
74+ // async function test() {
75+ // const db2 = await mongoose.createConnection('mongodb+srv://seconddbtest:seconddbtest@cluster0.yhztme0.mongodb.net/?retryWrites=true&w=majority');
76+ // console.log('connection to user provided db established..');
77+ // }
6178 // Check for existing user in DB, if found, connect to load application based on database type
6279 return User . findOne ( { username : username } )
6380 . then ( async ( data ) => {
64- console . log ( 'Hi, inside ipcMain.on connect in data.ts!' ) ;
81+ console . log ( 'Hi, inside ipcMain.on connect in data.ts! User db is working, testing second db. ' ) ;
6582 const databaseType = data . services [ index ] [ 1 ]
6683 const appURI = data . services [ index ] [ 2 ]
6784 console . log ( 'database type' , databaseType ) ;
6885 console . log ( 'appURI' , appURI ) ;
6986 if ( databaseType === 'MongoDB' ) {
70- await connectMongo ( index , appURI )
87+ const shouldbedb = await connectMongo ( index , appURI ) ;
88+ // console.log(shouldbedb);
89+ // await connectMongo()
7190 currentDatabaseType = databaseType ;
7291 message . sender . send ( 'databaseConnected' , 'connected!' ) ;
7392 } else if ( databaseType === 'SQL' ) {
@@ -114,7 +133,7 @@ ipcMain.on('connect', async (message: Electron.IpcMainEvent, username: string, i
114133ipcMain . on ( 'servicesRequest' , async ( message : Electron . IpcMainEvent ) => {
115134 try {
116135 let result : any ;
117-
136+ console . log ( 'Hi, inside data.ts - servicesRequest.' ) ;
118137 // Mongo Database
119138 if ( currentDatabaseType === 'MongoDB' ) {
120139 // Get all documents from the services collection
@@ -129,6 +148,7 @@ ipcMain.on('servicesRequest', async (message: Electron.IpcMainEvent) => {
129148 result = result . rows ;
130149 }
131150
151+ console . log ( 'Sending the following result to frontend:' , result ) ;
132152 // Async event emitter - send response
133153 message . sender . send ( 'servicesResponse' , JSON . stringify ( result ) ) ;
134154 // eslint-disable-next-line no-shadow
@@ -698,6 +718,13 @@ ipcMain.on('eksMetricsRequest', async (message:Electron.IpcMainEvent, username:
698718// }
699719// );
700720
721+ /**
722+ * @event awsAppInfoRequest - invoked in fetchAwsAppInfo in ipcRenderer
723+ * @desc Connects to user or guest database and returns a reponse object with the typeOfService,
724+ * region, and awsURL of the services at provided appIndex.
725+ * @params username:
726+ * index:
727+ */
701728ipcMain . on (
702729 'awsAppInfoRequest' ,
703730 async ( message : Electron . IpcMainEvent , username : string , appIndex : number ) => {
0 commit comments