-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
45 lines (40 loc) · 1.23 KB
/
index.js
File metadata and controls
45 lines (40 loc) · 1.23 KB
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
import express, { application } from "express";
import { connect, set } from "mongoose";
import dotenv from "dotenv";
import helmet from "helmet";
import morgan from "morgan";
import {
allPostsRouter,
authRouter,
commentRouter,
followRouter,
likePostRouter,
postRouter,
unfollowRouter,
unlikePostRouter,
userRouter,
} from "./router/index.js";
import { ConnectDB } from "./config/Database.js";
import validate from "./middleware/AuthMiddleware.js";
const app = express();
dotenv.config();
ConnectDB();
app.use(express.json());
app.use(helmet({
contentSecurityPolicy: false,
}));
app.use(morgan("common"));
// Routes
app.use("/api/authenticate", authRouter);
app.use("/api/follow", validate, followRouter);
app.use("/api/unfollow", validate, unfollowRouter);
app.use("/api/user", validate, userRouter);
app.use("/api/posts", validate, postRouter);
app.use("/api/like", validate, likePostRouter);
app.use("/api/unlike", validate, unlikePostRouter);
app.use("/api/comment", validate, commentRouter);
app.use("/api/all_posts", validate, allPostsRouter);
app.listen(process.env.PORT, () =>
console.log(`Developement Server is running on port ${process.env.PORT}...`)
);
export default app;