@@ -8,13 +8,19 @@ const User = require('../models/UserModel')
88const mongoose = require ( 'mongoose' ) ;
99// const db = require('../databases/mongo')
1010
11- const MONGO_URI = ''
11+ const MONGO_URI = 'mongodb+srv://chronoslany:chronoslany@cluster0.tvzzzbv.mongodb.net/?retryWrites=true&w=majority' ;
1212
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+ // })
1722
23+ // may need to first check if db has a current user and if not, change it to guest
1824// GLOBAL VARIABLES
1925let currentUser = 'guest' ;
2026const settingsLocation = path . resolve ( __dirname , '../../settings.json' ) ;
@@ -67,6 +73,8 @@ function clearGuestSettings() {
6773 */
6874ipcMain . on ( 'addApp' , ( message : IpcMainEvent , application : any ) => {
6975 const newApp = JSON . parse ( application )
76+ console . log ( 'parsed newApp: ' , newApp ) ;
77+ console . log ( 'currentUser' , currentUser ) ;
7078 const createdOn = moment ( ) . format ( 'lll' ) ;
7179 newApp . push ( createdOn ) ;
7280
@@ -107,6 +115,19 @@ ipcMain.on('addApp', (message: IpcMainEvent, application: any) => {
107115 * @return New list of applications
108116 */
109117ipcMain . 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+
110131 // Retrieves file contents from settings.json
111132 const settings = JSON . parse ( fs . readFileSync ( settingsLocation ) . toString ( 'utf8' ) ) ;
112133 const services = settings [ currentUser ] . services ;
@@ -118,7 +139,7 @@ ipcMain.on('addAwsApp', (message: IpcMainEvent, application: any) => {
118139 const newAwsApp = JSON . parse ( application ) ;
119140
120141 // Add a creation date to the application on the 5th index
121- const createdOn = moment ( ) . format ( 'lll' ) ;
142+ // const createdOn = moment().format('lll');
122143 newAwsApp . splice ( 5 , 0 , createdOn ) ;
123144
124145 // Add app to list of applications
0 commit comments