-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
28 lines (23 loc) · 895 Bytes
/
index.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
require('./lib/cron');
const log = require('./lib/log');
const restify = require('restify');
const server = restify.createServer({name: 'news-microservice', log});
const snippetsUpdateHandler = require('./lib/handlers/snippets-update');
const snippetsHandler = require('./lib/handlers/snippets');
const fakeSnippetsHandler = require('./lib/handlers/fake-snippets');
const articleHandler = require('./lib/handlers/article');
server.pre(restify.pre.userAgentConnection());
server.use(restify.queryParser());
server.use(restify.throttle({
burst: 10,
rate: 3,
ip: true
}));
server.use(restify.CORS());
server.get('/snippets-update', snippetsUpdateHandler);
server.get('/snippets', snippetsHandler);
server.get('/fake-snippets', fakeSnippetsHandler);
server.get('/article', articleHandler);
server.listen(9191, () => {
log.info('%s has been started at %s', server.name, server.url);
});