-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
27 lines (19 loc) · 606 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
const express = require('express');
require('dotenv').config();
const connectToDatabase = require('./config/db');
const authRouter = require('./routes/authRoute');
const app = express();
const cors = require('cors');
app.use(express.json());
app.use(cors())
const port = process.env.PORT || 4200;
connectToDatabase();
// API routes
app.use('/auth', authRouter);
app.get('/', function (req, res) {
res.status(200).send("Welcome!");
});
// Start the server to ensure both HTTP and WebSocket requests are handled:
server.listen(port, () => {
console.log(`Server is running on port # ${port}`);
});