-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.js
More file actions
37 lines (27 loc) · 860 Bytes
/
Copy pathapp.js
File metadata and controls
37 lines (27 loc) · 860 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
const express = require ('express');
const cookieParser = require('cookie-parser');
const bodyParser = require('body-parser');
const app = express();
const http = require('http');
const notify =require('./route/notify');
const redis = require('redis');
const rclient =redis.createClient(6379,'127.0.0.1');
const cors = require('cors');
rclient.on('error',function(err){
console.log('Error'+err);
})
var subpath_v1 = express();
app.use(cors());
app.use(bodyParser.urlencoded({ extended: false }));
app.use(bodyParser.json());
app.use(cookieParser());
app.use("/v1", subpath_v1);
subpath_v1.use(cors());
subpath_v1.use(bodyParser.urlencoded({ extended: false }));
subpath_v1.use(bodyParser.json());
subpath_v1.use(function(req,res,next){
req.cache =rclient;
next();
})
subpath_v1.use('/notify',notify);
http.createServer(app).listen(8888);