-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathindex.js
32 lines (29 loc) · 881 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
29
30
31
32
const express = require('express');
const http = require('http');
const cors = require('cors');
const socketService = require('./services/socket');
const apiRoute = require('./routes/api.routes');
require('dotenv').config();
const PORT = process.env.PORT || 5000;
const app = express();
const server = http.createServer(app);
app.use(
cors({
origin: process.env.CLIENT_URL,
methods: 'GET,HEAD,PUT,PATCH,POST,DELETE',
allowedHeaders: 'Content-Type',
}),
);
app.use(express.json());
app.use('/api', apiRoute);
app.use('/', (req, res) =>
res.send(`
<div style="height:100%; width:100%; text-align:center">
<h1>Server is Running ;)</h1>
<div>Codestream is hosted on Vercel
<a href="https://codestream.vercel.app/">https://codestream.vercel.app/</a>
</div></div>
`),
);
socketService(server);
server.listen(PORT, () => console.log('Server started!!'));