-
Notifications
You must be signed in to change notification settings - Fork 0
/
server.ts
36 lines (30 loc) · 975 Bytes
/
server.ts
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
/** @format */
import * as Express from "express";
let app: Express.Application;
app = Express();
const http = require("http");
const cors = require("cors");
const cookie = require("cookie-parser");
import { Server, Socket } from "socket.io";
import { userRouter } from "./Routes/userRouter";
import { itemsPool, connectMongo } from "./data/connectDB";
import { queryUser, insertUser, deleteUser } from "./user/userController";
import { tweetRouter } from "./Routes/tweetRouter";
import { connectSocket } from "./message/chatController";
//Middleware
app.use(cookie());
app.use(cors());
app.use(Express.json());
app.use(Express.urlencoded({ extended: false }));
//Database
itemsPool;
connectMongo();
//Socket server
const httpServer = http.createServer(app);
connectSocket(httpServer);
//Routes
app.use("/", userRouter);
app.use("/tweet", tweetRouter);
httpServer.listen(4000, () => {
console.log("running on http port 3000");
});