Skip to content

Commit 377caaf

Browse files
committed
updating 'awsAppInfoRequest' in data.ts to use with database
1 parent 5ddddc2 commit 377caaf

File tree

1 file changed

+21
-1
lines changed

1 file changed

+21
-1
lines changed

electron/routes/data.ts

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -594,10 +594,28 @@ ipcMain.on(
594594
}
595595
);
596596

597+
// ELENA WHERE I LEFT OFF
597598
ipcMain.on(
598599
'awsAppInfoRequest',
599600
async (message: Electron.IpcMainEvent, username: string, appIndex: number) => {
600-
try {
601+
602+
if(username !== 'guest'){
603+
return User.findOne({username: username})
604+
.then((data) => {
605+
console.log('DB returned user data: ', data);
606+
const { services } = data;
607+
const [typeOfService, region, awsUrl] = [services[4], services[2], services[9]];
608+
const response = {
609+
typeOfService, region, awsUrl
610+
}
611+
message.sender.send('awsAppInfoResponse', JSON.stringify(response));
612+
})
613+
.catch((error) => {
614+
console.log('Error in awsAppInfoRequest in data.ts');
615+
})
616+
}
617+
else {
618+
try {
601619
const fileContents = JSON.parse(fs.readFileSync(settingsLocation, 'utf8'));
602620
const userAwsService = fileContents[username]?.services[appIndex];
603621

@@ -613,6 +631,8 @@ ipcMain.on(
613631
console.log('Error in awsAppInfoRequest', message);
614632
message.sender.send('awsAppInfoResponse', { typeOfService: '', region: '' , awsUrl: ''});
615633
}
634+
}
635+
616636
}
617637
);
618638

0 commit comments

Comments
 (0)