-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.js
28 lines (25 loc) · 918 Bytes
/
index.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
let express = require('express');
let cors = require('cors');
let app = express();
let api_route = require('./api_route');
app.use(cors());
app.use(function (req, res, next) {
res.setHeader('Access-Control-Allow-Origin', '*');
res.setHeader('Access-Control-Allow-Methods', 'GET, POST, OPTIONS');
res.setHeader('Access-Control-Allow-Headers', 'X-Requested-With,Content-type,Accept');
res.setHeader('Access-Control-Allow-Credentials', true);
next();
});
app.use('/api/v2', api_route);
app.get('*', function (req, res, next) {
res.send("All Error");
});
app.get('/404', function (req, res, next) {
res.send("404 Error");
});
const api_controller = require('./controllers/ApiController');
const port = 1901;
app.listen(port, async function() {
// await api_controller.summary();
console.log( '[' + new Date().toLocaleString() + '] ' +'Server listening http://127.0.0.1:' + port);
});