Skip to content

Commit

Permalink
Console logs are gone
Browse files Browse the repository at this point in the history
  • Loading branch information
SSBinks committed Jan 26, 2017
1 parent e0b2309 commit a1880fd
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 50 deletions.
1 change: 0 additions & 1 deletion models/assignment.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
var mongoose = require('mongoose');
var moment = require('moment');
var Schema = mongoose.Schema;
var AssignmentType = require('./assignmenttype');
var AssignmentSchema = new Schema ({
title: String,
dueDate: {type: Date, max: moment().add(2, 'years').calendar()},
Expand Down
25 changes: 0 additions & 25 deletions models/assignmenttype.js

This file was deleted.

27 changes: 3 additions & 24 deletions server.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ var moment = require('moment');
var bodyParser = require('body-parser');
var mongoose = require('mongoose');
var Assignment = require('./models/assignment');
var AssignmentType = require('./models/assignmenttype');
var dotenv = require('dotenv').config();
var port = process.env.PORT || 8081;
mongoose.connect(process.env.MONGODB_LINK);
Expand All @@ -16,15 +15,14 @@ app.use(bodyParser.json());

var router = express.Router();
router.use(function(req, res, next) {
console.log('Its ALIVE');
console.log('Boot Up');
next();
});

//This works
router.route('/')
.get(function(req, res) {
const today = moment().utc().subtract(1, 'days').format();
console.log('Today is ' + today);
Assignment.find({dueDate: {$gt: today}}).sort({dueDate: 'ascending'}).exec(function (err, assignment){
if(err)
res.send(err);
Expand All @@ -35,27 +33,20 @@ router.route('/')

router.route('/assign')
.post( function(req, res){
// res.send(err);
var assign = new Assignment();
// console.log('>>>>This is type object' + JSON.stringify(type))
assign.title = req.body.title;
console.log( 'this is Body' + JSON.stringify(req.body));
console.log( 'this is Title' + req.body.title);
assign.dueDate = moment(req.body.dueDate).format('L');
console.log( 'this is DATE' + req.body.dueDate);
assign.progress = req.body.progress;
assign.complete = req.body.complete;
assign.categories = req.body.categories;
assign.part = req.body.part;
console.log( 'this is complete' + req.body.completionAmount);
assign.completionAmount = req.body.completionAmount;
console.log( 'this is goal' + req.body.goal);
assign.goal = req.body.goal;
assign.dailyGoal = req.body.dailyGoal;
assign.save(function(err){
if(err)
res.send('derp this broke' + err);
// console.log('>>>>This is type object ' + JSON.stringify(type))


});
res.json({ message: "Come on ladies let us get into formation"});
Expand Down Expand Up @@ -85,14 +76,9 @@ router.route('/assign/update/:assign_id')
Assignment.findById(req.params.assign_id, function(err, assignment) {
if(err)
res.send(err);
console.log('the id ' + assignment);
let keys = Object.keys(req.body);
for(var i =0; i < keys.length; i++){

let key = keys[i];
console.log('the key is ' + key);
console.log('the second ' + req.body[key]);

assignment[key] = req.body[key];
}
assignment.save(function(err) {
Expand All @@ -103,14 +89,7 @@ router.route('/assign/update/:assign_id')
});
});

router.route('/assign/categories/:categories')
.get(function(req, res) {
AssignmentType.find({categories: req.params.categories}, function(err, type){
if(err)
res.send(err);
res.json(type);
});
})


app.use('/', router)
app.listen(port);
Expand Down

0 comments on commit a1880fd

Please sign in to comment.