-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.js
35 lines (28 loc) · 853 Bytes
/
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
const express = require('express'),
bodyParser = require('body-parser'),
app = express(),
config = require('./config/default'),
path = require('path'),
dict = require('./src/service/dictionary');
app.use(bodyParser.json());
app.use(require('./src/routes'));
app.get('/app/privacy', (request, response, next) => {
response.sendFile(path.join(__dirname + '/static/html/privacy.html'));
});
app.get('/', (request, response, next) => {
const { query } = request;
try {
dict
.lookup((query.q))
.then((body) => {
response.json(body)
})
.catch(err => response.send(err));
} catch (e) {
next(e);
response.send(e)
}
});
app.listen(config.server.port, () => {
console.log('Server running on port %s', config.server.port)
});