-
Notifications
You must be signed in to change notification settings - Fork 104
/
server.js
32 lines (26 loc) · 1.15 KB
/
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
const express = require('express');
const logger = require('winston');
const app = express();
const port = 5000;
app.get('/', (request, response) => {
response.send(`Hello, I'm alive`);
logger.info('Responded to GET request on /')
});
app.get('/api/me', (request, response) => {
response.send('{"name": "Arthur Dent", "location": "Earth"}');
logger.info('Responded to GET request on /api/me')
});
app.get('/api/work', (request, response) => {
response.send('[{"yearFrom": "2010", "yearTo": "2018", "place": "BBC Radio", "comment": "Was doing stuff"}, {"yearFrom": "2009", "yearTo": "2010", "place": "The coffee shop", "comment": "Making coffee"}]');
logger.info('Responded to GET request on /api/work')
});
app.get('/api/education', (request, response) => {
response.send('[{"yearFrom": "2005", "yearTo": "2007", "place": "University 1", "comment": "Studying"}, {"yearFrom": "2001", "yearTo": "2004", "place": "Barista academy", "comment": "Made coffee"}]');
logger.info('Responded to GET request on /api/edu')
});
app.listen(port, (err) => {
if (err) {
return logger.error('something bad happened', err)
}
logger.info(`server is listening on ${port}`)
});