-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathserver.js
30 lines (24 loc) · 957 Bytes
/
server.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
var express = require('express');
var bodyParser = require('body-parser');
var path = require('path');
var mongodb = require('./server/routes/mongodb/mongo.api');
var cors = require('cors');
var socketFn = require('./server/socket/socket');
app = express();
app.use(cors());
app.use(bodyParser.json({ limit: '1mb' }));
app.use(bodyParser.urlencoded({ limit: '1mb', extended: false }));
// Angular DIST output folder
app.use(express.static(path.join(__dirname, 'dist/nys-chat')));
//mongo api
app.use('/mongodb', mongodb);
app.use('/chatfiles', express.static(path.join(__dirname, 'server/filesystem/chats')));
// Send all other requests to the Angular app
app.get('*', (req, res) => {
res.sendFile(path.join(__dirname, 'dist/nys-chat/index.html'));
});
//setting port and starting server
const port = process.env.PORT || '3000';
var server = app.listen(port, () => { console.log(`Running on localhost:${port}`) });
//Socket setup
socketFn(server);