Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .idea/jsLibraryMappings.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

34 changes: 34 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 1 addition & 1 deletion app/api/user.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
5 changes: 3 additions & 2 deletions config/config.dev.js
Original file line number Diff line number Diff line change
@@ -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
}
};
};
9 changes: 8 additions & 1 deletion gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand All @@ -24,7 +26,8 @@ var paths = {


jshintPaths: ['public/js/**/*.js'],

sourceRootNode: path.join(__dirname, 'app'),
sourceRootServer: path.join(__dirname, 'server.js')
};

var sources = {
Expand Down Expand Up @@ -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));
});

Expand Down
7 changes: 6 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
}
14 changes: 10 additions & 4 deletions server.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand All @@ -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;
Expand Down