forked from naamnamm/chat-app
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserver.js
More file actions
30 lines (21 loc) · 699 Bytes
/
server.js
File metadata and controls
30 lines (21 loc) · 699 Bytes
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
require('dotenv').config();
const path = require('path');
const express = require('express');
const app = express();
const http = require('http');
const server = http.createServer(app);
const io = require('socket.io')(server);
const cors = require('cors');
const port = process.env.PORT || 5000;
app.use(express.json());
app.use(cors());
app.use(function (req, res, next) {
req.io = io;
next();
});
app.use('/users', require('./routes/jwtAuth'));
app.use(express.static(path.join(__dirname, 'client/build')));
app.get('/*', (req, res) => {
res.sendFile(path.join(__dirname, 'client/build', 'index.html'));
});
server.listen(port, () => console.log(`server started on port ${port}`));