-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
29 lines (23 loc) · 852 Bytes
/
index.js
File metadata and controls
29 lines (23 loc) · 852 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
var app = require('express')();
var bodyParser = require('body-parser');
var morgan = require('morgan');
var port = process.env.PORT || 8080;
var apiRouter = require('./api/index');
var mongoCon = require('./lib/mongo').Connection;
mongoCon.connectToMongo();
var redisCon = require('./lib/redis').Connection;
(async () => {
await redisCon.connectToRedis();
})();
// redisCon.client.zrange(['h', 0, -1], (err, ans) => {console.log(ans)});
// var db_config = require('./_config/database');
app.get('/', function (req, res) {
res.send('Hello! The API is at http://localhost:' + port + '/api');
});
app.use(bodyParser.urlencoded({ extended: false }));
app.use(bodyParser.json());
app.use(bodyParser.raw());
app.use(morgan('dev'));
app.use('/api', apiRouter);
var server = app.listen(port);
console.log('Magic happens at http://localhost:' + port);