-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
32 lines (26 loc) · 964 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
29
30
31
32
const express = require('express');
const server = express();
const helmet = require('helmet');
const cors = require('cors');
const bodyParser = require('body-parser');
const routers = require('./controller');
const redisClient = require('./config/redisClient');
const crawl = require('./job/crawl');
const logger = require('./utils/logger');
//Setup
server.use(helmet());
server.use(cors());
server.use(bodyParser.urlencoded({ extended: false, limit: '50mb' }));
server.use(bodyParser.json({ limit: '50mb' }));
// Move the following two lines before the `routers` middleware
server.use(express.json()); // Parse JSON-encoded bodies
server.use(express.urlencoded({ extended: true })); // Parse URL-encoded bodies
server.use(routers);
server.listen(3003, async () => {
await redisClient.connect();
crawl.process();
});
logger.info('Server is running on port ' + 3003);
server.on('error', err => {
console.error(err);
});