forked from Xiphiar/teddy-api
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.jsold
58 lines (41 loc) · 1.31 KB
/
index.jsold
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
51
52
53
54
55
56
57
58
const express = require('express');
const bodyParser = require('body-parser');
const cors = require('cors');
var http = require('http');
var https = require('https');
var fs = require('fs');
const path = require("path");
const app = express();
const port = process.env.PORT || 3176;
const sslPort = process.env.PORT || 3443;
const poolsRouter = require('./routes/pools');
const contractsRouter = require('./routes/contracts');
const tokensRouter = require('./routes/tokens');
const helmet = require('helmet');
var sslOptions = {
key: fs.readFileSync(path.resolve(__dirname, "./key.pem")),
cert: fs.readFileSync(path.resolve(__dirname, "./cert.pem"))
};
app.use(bodyParser.json());
app.use(helmet());
app.use(cors());
app.use('/pools', poolsRouter);
app.use('/contracts', contractsRouter);
app.use('/tokens', tokensRouter);
app.use(bodyParser.json());
app.use(
bodyParser.urlencoded({
extended: true,
})
);
app.get('/', (req, res) => {
res.json({'message': 'ok'});
})
//app.listen(port, () => {
// console.log(`Example app listening at http://localhost:${port}`)
//});
http.createServer(app).listen(port);
console.log(`Example app listening at http://localhost:${port}`)
https.createServer(sslOptions, app).listen(sslPort);
console.log(`Example app listening at http://localhost:${sslPort}`)
module.exports = app;