-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathserver.js
44 lines (36 loc) · 1.04 KB
/
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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
const socketIo = require("socket.io");
const http = require("http");
const express = require("express");
const mongoose = require("mongoose");
const multer = require("multer");
const app = express();
const port = 4000;
const cors = require("cors");
app.use(express.json());
app.use(cors());
const conversationsRoutes = require("./routes/conversationsRoutes");
const usersRoutes = require("./routes/usersRoutes");
const filesRoutes = require("./routes/filesRoutes");
// connecting to DB
mongoose
.connect("mongodb://localhost:27017/Ai-rAssistDB", {})
.then(async (result) => {
console.log("connected to mongodb");
})
.catch((err) => {
console.log(err);
});
// adding routes
app.use(usersRoutes);
app.use(conversationsRoutes);
app.use(filesRoutes);
// app.listen(port, () => {
// console.log(`Server is running on port ${port}`);
// });
// module.exports = server;
const server = http.createServer(app);
// const io = socketIo(server);
// io.use(cors());
server.listen(port, () => {
console.log(`Server is running on port ${port}`);
});