@@ -8,13 +8,19 @@ const User = require('../models/UserModel')
8
8
const mongoose = require ( 'mongoose' ) ;
9
9
// const db = require('../databases/mongo')
10
10
11
- const MONGO_URI = ''
11
+ const MONGO_URI = 'mongodb+srv://chronoslany:[email protected] /?retryWrites=true&w=majority' ;
12
12
13
- mongoose . connect ( MONGO_URI , {
14
- useNewUrlParser : true ,
15
- useUnifiedtopology : true ,
16
- } )
13
+ main ( ) . catch ( err => console . log ( err ) ) ;
14
+ async function main ( ) {
15
+ await mongoose . connect ( MONGO_URI ) ;
16
+ console . log ( 'user info db connection established...' )
17
+ }
18
+ // mongoose.connect(MONGO_URI, {
19
+ // useNewUrlParser: true,
20
+ // useUnifiedtopology: true,
21
+ // })
17
22
23
+ // may need to first check if db has a current user and if not, change it to guest
18
24
// GLOBAL VARIABLES
19
25
let currentUser = 'guest' ;
20
26
const settingsLocation = path . resolve ( __dirname , '../../settings.json' ) ;
@@ -67,6 +73,8 @@ function clearGuestSettings() {
67
73
*/
68
74
ipcMain . on ( 'addApp' , ( message : IpcMainEvent , application : any ) => {
69
75
const newApp = JSON . parse ( application )
76
+ console . log ( 'parsed newApp: ' , newApp ) ;
77
+ console . log ( 'currentUser' , currentUser ) ;
70
78
const createdOn = moment ( ) . format ( 'lll' ) ;
71
79
newApp . push ( createdOn ) ;
72
80
@@ -107,6 +115,19 @@ ipcMain.on('addApp', (message: IpcMainEvent, application: any) => {
107
115
* @return New list of applications
108
116
*/
109
117
ipcMain . on ( 'addAwsApp' , ( message : IpcMainEvent , application : any ) => {
118
+
119
+ const newAWSApp = JSON . parse ( application ) ;
120
+ console . log ( 'parsed newApp: ' , newAWSApp ) ;
121
+ console . log ( 'currentUser' , currentUser ) ;
122
+ const createdOn = moment ( ) . format ( 'lll' ) ;
123
+ newAWSApp . push ( createdOn ) ;
124
+
125
+ if ( currentUser !== 'guest' ) {
126
+
127
+ }
128
+
129
+ // if user is not guest, should not have to pull info from settings.json file
130
+
110
131
// Retrieves file contents from settings.json
111
132
const settings = JSON . parse ( fs . readFileSync ( settingsLocation ) . toString ( 'utf8' ) ) ;
112
133
const services = settings [ currentUser ] . services ;
@@ -118,7 +139,7 @@ ipcMain.on('addAwsApp', (message: IpcMainEvent, application: any) => {
118
139
const newAwsApp = JSON . parse ( application ) ;
119
140
120
141
// Add a creation date to the application on the 5th index
121
- const createdOn = moment ( ) . format ( 'lll' ) ;
142
+ // const createdOn = moment().format('lll');
122
143
newAwsApp . splice ( 5 , 0 , createdOn ) ;
123
144
124
145
// Add app to list of applications
0 commit comments