-
Notifications
You must be signed in to change notification settings - Fork 1
/
server.js
32 lines (25 loc) · 908 Bytes
/
server.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
var express = require('express');
var bodyParser = require('body-parser');
var mongoose = require('mongoose');
var student = require('./Database/studentController.js');
var db = mongoose.connect(process.env.MONGODB_URI || 'mongodb://localhost/lessonDB');
var db = mongoose.connection;
db.on('error', console.error.bind(console, 'connection error:'));
db.once('open', function() {
console.log('connected to MONGODB');
});
var app = express();
app.use(bodyParser.json());
app.use(express.static(__dirname + '/Client'));
//Retrieve list of all students and their assignments
app.get('/studentList', function(req, res){
student.returnStudentList(req, res);
});
//Assign a piece to a student
app.post('/assignments', function(req, res){
console.log(req.body);
student.createStudent(req.body);
});
app.listen(process.env.PORT || 3000, function(){
console.log('server listening on port 3000');
});