-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.js
37 lines (29 loc) · 923 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
36
37
const express = require('express');
const bodyParser = require('body-parser');
const logger = require('morgan');
const util = require('util');
const app = express();
app.use(logger('dev'));
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({ extended: true }));
app.locals.title = 'Deadpool backend';
const redis = require('redis');
const client = redis.createClient({
host: 'localhost',
port: '6379'
});
client.on('error', (err) => {
util.error('Error ' + err);
})
const { promisify } = require('util');
const getAsync = promisify(client.get).bind(client);
const setAsync = promisify(client.set).bind(client);
const delAsync = promisify(client.del).bind(client);
const runCache = require('./src/cache/sync');
runCache(setAsync, delAsync);
setInterval(() => {
runCache(setAsync, delAsync);
}, 60 * 60 * 1000);
let routes = require('./src/routes/routes');
routes(app, getAsync);
module.exports = app;