-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
50 lines (38 loc) · 889 Bytes
/
index.js
File metadata and controls
50 lines (38 loc) · 889 Bytes
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
const dotenv = require('dotenv');
dotenv.config();
// Body Parser for req/res
const bodyParser = require('body-parser');
const express = require('express');
/**
* Middleware Decleration
*/
// using CORS
const cors = require('cors');
// Helmet for request security.
const config = require('./config');
// Bunyan logger
const logger = require('./logger')();
// express init
const app = express();
// CORS
app.use(cors());
// Body Parser config
app.use(bodyParser.urlencoded({
parameterLimit: 10,
limit: '1mb',
extended: false,
}));
// Json Parser config
app.use(bodyParser.json());
// Configure databases here.
const elasticsearch = require('./elasticsearch');
app.use(
'/api/v1',
require('./routes/routes')({ logger, db: elasticsearch }),
);
/**
* Server
*/
app.listen(config.port, () => {
console.log(`Server listening on port: ${config.port}`);
});