forked from maxant/pactexamples
-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
55 lines (49 loc) · 1.36 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
'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"
}
}
);
});
//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);
});