-
Notifications
You must be signed in to change notification settings - Fork 0
/
server.js
47 lines (38 loc) · 1.13 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
45
46
47
const express = require("express");
const app = express();
const cors = require("cors");
const fileUpload = require("express-fileupload");
const io = require('socket.io')(8900);
const authApi = require("./routes/api/auth");
const chatApi = require("./routes/api/chats");
const contactsApi = require("./routes/api/contacts");
const groupChatsApi = require("./routes/api/groupChats");
const messagingApi = require("./routes/api/messaging");
const db = require("./util/db");
const sockets = require("./routes/sockets")(io);
app.use(express.urlencoded());
app.use(express.json());
app.use(cors());
app.use(
fileUpload({
createParentPath: true,
limits: {
fileSize: 8 * 1024 * 1024 * 1024, //8MB max file(s) size
},
})
);
app.use("/api/auth/", authApi);
app.use("/api/chat/", chatApi);
app.use("/api/messaging/", messagingApi);
app.use("/api/contacts/", contactsApi);
app.use("/api/groupchats/", groupChatsApi);
db.sync({ force: process.env.CI == "true" })
.then(() => {
app.listen("5000", () => {
console.log("Listening on port 5000");
});
})
.catch((e) => {
throw new Error(e);
});
module.exports = app;