-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.js
37 lines (28 loc) · 1.09 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
require('dotenv').config();
var http = require('http');
const l10n = require('jm-ez-l10n');
var cors = require('cors');
var exp = require('express');
var bodyParser = require("body-parser");
var app = exp();
l10n.setTranslationsFile('en', './constantMessage/messages.en.json');
app.use(l10n.enableL10NExpress);
app.use(bodyParser.json({ limit: '50mb' }));
app.use(bodyParser.urlencoded({ limit: '50mb', extended: true }));
app.use(cors());
app.use((req,res, next) => {
res.setHeader('Access-Control-Allow-Origin', '*');
res.setHeader('Access-Control-Allow-Methods', 'GET,POST,DELETE,PUT,OPTIONS,PATCH');
res.setHeader('Access-Control-Allow-Headers','X-Requested-With,authtoken,isadmintoken,Accept,Content-Type,Authorization')
// Pass to next layer of middleware
next();
});
app.use('/api', require('./routes/config'));
var server = http.createServer(app);
const io = require('socket.io')(server);
const socketFile = require('./helper/socket');
socketFile.socketData.createSocketServer(io);
app.set('socketio', io);
server.listen(process.env.SERVER_PORT, () => {
console.log("server started");
})