Skip to content

Commit 726e34c

Browse files
committed
created .env example template to help secure user database
1 parent 2964159 commit 726e34c

File tree

2 files changed

+25
-17
lines changed

2 files changed

+25
-17
lines changed

.env.example

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# This is a template for the .env file where you should store your MongoDB URI.
2+
# Duplicate this file in the root directory, and then rename the duplicated file to '.env'
3+
# Paste the MongoDB URI for your User database in place of the example URI provided below.
4+
5+
USER_DB_URI='mongodb+srv://yourusername:[email protected]/'

electron/models/UserModel.ts

Lines changed: 20 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,27 @@
1+
require('dotenv').config();
2+
13
// INSERT URI TO MONGODB TO SET UP USER DATABASE
2-
const MONGO_URI = 'mongodb+srv://seconddbtest:[email protected]/?retryWrites=true&w=majority';
3-
const mongoose = require('mongoose')
4+
const MONGO_URI = process.env.USER_DB_URI;
5+
console.log(MONGO_URI);
6+
// const MONGO_URI = process.env.CHRONOS_USER_DB_URI;
7+
const mongoose = require('mongoose');
48

5-
const db2 = mongoose.createConnection(MONGO_URI)
6-
// .then(() => {
7-
// console.log('Connected to User database...');
8-
// })
9-
// .catch(err => {
10-
// console.log('Error connecting to User database: ', err);
11-
// })
9+
const userDB = mongoose.createConnection(MONGO_URI);
10+
// .then(() => {
11+
// console.log('Connected to User database...');
12+
// })
13+
// .catch(err => {
14+
// console.log('Error connecting to User database: ', err);
15+
// });
1216
// console.log('establishing connection to database');
1317

14-
1518
const userSchema = new mongoose.Schema({
16-
username: {type: String, required:true, unique: true},
17-
password: {type: String, required:true},
18-
email: String,
19-
services: [],
20-
mode: {type: String, default: 'light'}
19+
username: { type: String, required: true, unique: true },
20+
password: { type: String, required: true },
21+
email: String,
22+
services: [],
23+
mode: { type: String, default: 'light' },
2124
});
2225

23-
const UserModel = db2.model('users', userSchema);
24-
module.exports = UserModel;
26+
const UserModel = userDB.model('users', userSchema);
27+
module.exports = UserModel;

0 commit comments

Comments
 (0)