-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
105 lines (75 loc) · 2.65 KB
/
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
'use strict';
if (process.env.NODE_ENV !== 'dev' &&
process.env.NODE_ENV !== 'prod' &&
process.env.NODE_ENV !== 'test'
) {
console.log(
`Please specify one of the following environments to run your server
- test
- dev
- prod
Example : NODE_ENV=dev pm2 start app.js`
);
throw 'abc';
return '';
}
process.env.NODE_CONFIG_DIR = __dirname + '/config/';
/** Node Modules **/
const config = require('config');
const express = require('express');
const path = require('path');
const bodyParser = require('body-parser');
const fs = require('fs-extra');
const morgan = require('morgan');
const http = require('http');
const https = require('https');
const colors = require('colors');
const logger = require('./libs/logging');
const logconf = {};
const updater = require('./routes/updater');
/** Routes **/
const ico = require('./routes/ico');
const scam = require('./routes/scam');
const report = require('./routes/report');
const wrapper = require('./routes/wrapper');
/** Socket **/
// const socket = require('./routes/socket');
const app = express();
app.set('port', process.env.PORT || config.get('port'));
// app.use(express.static('public'));
app.use(morgan('dev'));
app.use(bodyParser.json({limit: '100mb'}));
app.use(bodyParser.urlencoded({limit: '50mb', extended: true}));
// app.set('views','./src/views');
// app.set('view engine','ejs');
app.use(function (req, res, next) {
res.setHeader('Access-Control-Allow-Origin', '*');
res.setHeader('Access-Control-Allow-Methods', 'GET, POST, OPTIONS, PUT, PATCH, DELETE');
res.setHeader('Access-Control-Allow-Headers', 'X-Requested-With,content-type, Authorization');
res.setHeader('Access-Control-Allow-Credentials', true);
next();
});
/**--------------------------------------------------------
* API to check if server is running or not
*---------------------------------------------------------
*/
app.get('/ping', function (req, res) {
res.send(200, {}, { pong: true });
});
// app.get('/', (req, res)=>{
// res.render('home.ejs');
// });
//ICO APIs
app.get('/api/ico', ico.allICO);
// Scam APIs
app.get('/api/scam/analysis', scam.analysis);
app.get('/api/scam/search', scam.search);
app.post('/api/report/insert', report.insert);
// API wrapper
app.get('/api/wrapper', wrapper.apiWrapper);
// app.get('/editor/:editorName', editor.initialize);
// app.post('/editor/:editorName', editor.initialize);
// app.get('/users/:editorName', editor.getUserList);
var httpsServer = http.createServer(app).listen(app.get('port'), function () {
console.log('Express server listening on port ' + app.get('port'));
});