-
Notifications
You must be signed in to change notification settings - Fork 9
/
test-server.js
42 lines (37 loc) · 1.04 KB
/
test-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
33
34
35
36
37
38
39
40
41
42
const express = require('express');
const bodyParser = require('body-parser');
const app = express();
// parse application/x-www-form-urlencoded
app.use(bodyParser.urlencoded({ extended: true, }));
app.use(bodyParser.json());
app.post('/', (req, res) => {
const data = req.body.hash;
console.log('this is data:', data);
if (data === 'handshake') {
res.send({ status: 200, until: '2017-04-11T22:51:29.410Z', });
} else {
res.send({ status: 400, message: 'Bad Request', });
}
});
app.get('/', (req, res) => {
const data = req.body.hash;
console.log('this is data:', data);
const response = {
status: 200,
sessions: {
'session._id': {
_id: 'session-id',
name: 'session-name',
cohort: 'session-cohort',
submittable: {
PROJECT: [
{ _id: 'abc', name: 'project-name', },
],
},
},
},
};
console.log(response);
res.send(response);
});
app.listen(3000, () => console.log('http://localhost:3000'));