diff --git a/.idea/jsLibraryMappings.xml b/.idea/jsLibraryMappings.xml
new file mode 100644
index 0000000..b8387eb
--- /dev/null
+++ b/.idea/jsLibraryMappings.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/misc.xml b/.idea/misc.xml
new file mode 100644
index 0000000..28a804d
--- /dev/null
+++ b/.idea/misc.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/vcs.xml b/.idea/vcs.xml
new file mode 100644
index 0000000..94a25f7
--- /dev/null
+++ b/.idea/vcs.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/README.md b/README.md
index 9510ea7..58a782b 100644
--- a/README.md
+++ b/README.md
@@ -3,3 +3,37 @@ Course Planner
A webapp for planning which courses to take and which year to take them in.
+
+## .env file and Database
+
+1. Create a *.env* text file in the root directory
+
+Example structure:
+
+ DB_SECRET=secret_here
+ DB_USER=username_here
+ DB_PASS=password_here
+
+2. Create your own DB
+
+Go to: https://mlab.com
+
+Create a sandbox MongoDB Database.
+
+You should get a URL for the following.
+
+3. Add user for the Database
+
+Add a user with a password.
+
+Then add that user and password to the *.env* file.
+
+4. Set url database in *config/config.dev.js*
+
+ url: 'mongodb://' + process.env.DB_USER + ':' + process.env.DB_PASS + '@ds161179.mlab.com:61179/courseplanner'
+
+ The last part of the URL
+
+ @ds161179.mlab.com:61179/courseplanner
+
+ Should be changed to your specific URL
\ No newline at end of file
diff --git a/app/api/user.js b/app/api/user.js
index 5b315d4..4ea402f 100644
--- a/app/api/user.js
+++ b/app/api/user.js
@@ -6,7 +6,7 @@
var jwt = require('jwt-simple');
var UserModel = require('../models/user');
- var config = require('../../config/config.js');
+ var config = require('../../config/config');
var init = function(router) {
diff --git a/config/config.dev.js b/config/config.dev.js
index a2212fb..529f95f 100644
--- a/config/config.dev.js
+++ b/config/config.dev.js
@@ -1,6 +1,7 @@
module.exports = {
db: {
- url: 'mongodb://' + process.env.DB_USER + ':' + process.env.DB_PASS + '@ds063546.mlab.com:63546/course-planner',
+ local_url: 'mongodb://' + process.env.DB_USER + ':' + process.env.DB_PASS + '@ds161179.mlab.com:61179/courseplanner',
+ production_url: '',
secret: process.env.DB_SECRET
}
-};
+};
\ No newline at end of file
diff --git a/gulpfile.js b/gulpfile.js
index bd50ee1..1c76e9e 100644
--- a/gulpfile.js
+++ b/gulpfile.js
@@ -8,6 +8,8 @@ var clean = require('gulp-clean');
var series = require('stream-series');
var sass = require('gulp-sass');
var nodemon = require('gulp-nodemon');
+//const sourceMaps = require("gulp-sourcemaps");
+const path = require("path");
// --- Environment ---
var envs = {
@@ -24,7 +26,8 @@ var paths = {
jshintPaths: ['public/js/**/*.js'],
-
+ sourceRootNode: path.join(__dirname, 'app'),
+ sourceRootServer: path.join(__dirname, 'server.js')
};
var sources = {
@@ -93,11 +96,15 @@ gulp.task('views', function(){
gulp.task('server', function(){
return gulp.src(sources.server)
+ //.pipe(sourceMaps.init())
+ //.pipe(sourceMaps.write('.', { sourceRoot: paths.sourceRootServer}))
.pipe(gulp.dest(dest.dist));
});
gulp.task('node', function(){
return gulp.src(sources.node)
+ //.pipe(sourceMaps.init())
+ //.pipe(sourceMaps.write('.', { sourceRoot: paths.sourceRootNode}))
.pipe(gulp.dest(dest.node));
});
diff --git a/package.json b/package.json
index 1ed5f3a..550fdc2 100644
--- a/package.json
+++ b/package.json
@@ -40,11 +40,16 @@
"stream-series": "^0.1.1"
},
"scripts": {
+ "build": "gulp",
+ "buildstart": "npm run build && start",
"start": "node dist/server.js -p $PORT",
"postinstall": "gulp && bower install"
},
"bugs": {
"url": "https://github.com/khanny17/CoursePlanner/issues"
},
- "author": ""
+ "author": "",
+ "devDependencies": {
+ "gulp-sourcemaps": "^2.4.1"
+ }
}
diff --git a/server.js b/server.js
index cd04779..2bea759 100644
--- a/server.js
+++ b/server.js
@@ -4,8 +4,10 @@
//Load environment variables
require('dotenv').load();
+
+
// Modules
- var config = require(__dirname + '/config/config');
+ var config = require(__dirname + '/config/config.js');
var express = require('express');
var app = express();
var bodyParser = require('body-parser');
@@ -16,11 +18,15 @@
// Configuration
-
+
+ // Determines production or local database url
+ // TODO make this a passable argument
+ const DB_URL = config.db.local_url || config.db.production_url;
+
//DB
- mongoose.connect(config.db.url, function(err) {
+ mongoose.connect(DB_URL, function(err) {
console.log(err || 'Mongoose Connected Successfully'); //TODO on error, close application
- });//, {authMechanism: 'ScramSHA1'});
+ });
// Server port
var port = process.env.PORT || 8080;