-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathapp.js
107 lines (98 loc) · 2.51 KB
/
app.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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
'use strict';
const PORT = 8091;
const express = require('express');
const app = express();
app.post('/all', (req, res) => {
console.log("post/all");
res.status(200).send([
{
"title": "My first event",
"location": "Eversons Fry House",
"date": "2017-02-17T21:00:00.000"
}, {
"title": "My second event",
"location": "Shakin Pancakes",
"date": "2017-02-18T22:00:00.000"
}, {
"title": "A third event",
"location": "Dories Donuts",
"date": "2017-02-19T09:00:00.000"
}
]);
})
;
app.get('/dictionary', (req, res) => {
console.log("get/dictionary");
res.status(200).send({
"tant": { //note, this does NOT match the value given in the pact consumer test
"title": "ant",
"asdf": 1
},
"john": {
"title": "john",
"date": "2017-04-08T22:33:31.000"
}
});
})
;
app.get('/dictionaryArray', (req, res) => {
console.log("get/dictionaryArray");
res.status(200).send({
"tant": [
{ //note, this does NOT match the value given in the pact consumer test
"title": "antony",
"asdf": 1
}
],
"john": [
{
"title": "john",
"date": "2017-04-08T22:33:31.000"
}, {
"title": "johnny",
"date": "2017-04-09T22:33:31.000"
}
]
});
})
;
app.get('/dictionaryNestedArray', (req, res) => {
console.log("get/dictionaryNestedArray");
res.status(200).send({
"newFeature": {},
"events": {
"tant": [
{ //note, this does NOT match the value given in the pact consumer test
"title": "ant",
"asdf": 1
}
],
"john": [
{
"title": "john",
"date": "2017-04-08T22:33:31.000"
}, {
"title": "johnny",
"date": "2017-04-09T22:33:31.000"
}
]
}
});
})
;
app.get('/primitive', (req, res) => {
console.log("get/primitive");
res.status(200).json(33);
})
;
//handle errors
app.use((err, req, res, next) => {
console.error(err.stack);
res.status(500).send('Something broke!');
})
;
//start server
app.listen(PORT, () => {
console.log('events listening on port ' + PORT);
})
;