-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
37 lines (30 loc) · 1006 Bytes
/
index.js
File metadata and controls
37 lines (30 loc) · 1006 Bytes
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
import express from "express";
import dotenv from "dotenv";
import DBCon from "./utils/db.js";
import AuthRoutes from "./routes/Auth.js";
import BlogsRoute from "./routes/blog.js";
import DashboardRouter from "./routes/Dashboard.js"
import cookieParser from "cookie-parser";
import helmet from "helmet";
import commentRouter from "./routes/comment.js";
import singlePostRouter from "./routes/singlePostRoute.js";
dotenv.config();
const PORT = process.env.PORT || 2000;
const app = express();
DBCon();
app.use(express.static('public'));
app.use(express.json());
app.use(cookieParser());
// Use helmet to secure headers, it sets several security headers by default
app.use(helmet());
app.get("/", (req, res) => {
res.send("Hello from backend");
});
app.use('/auth', AuthRoutes);
app.use('/blog', BlogsRoute);
app.use('/dashboard', DashboardRouter);
app.use('/comments', commentRouter);
app.use('/get', singlePostRouter);
app.listen(PORT, () => {
console.log(`App is running on port ${PORT}`);
});