-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.js
More file actions
39 lines (31 loc) · 1.07 KB
/
app.js
File metadata and controls
39 lines (31 loc) · 1.07 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
import express from "express";
import bodyParser from "body-parser";
import cookieParser from "cookie-parser";
import { configDotenv } from "dotenv";
import api from "./routes/api.js";
import errorHandlerMiddleware from "./middlewares/errorHandlerMiddleware.js";
import securityMiddleware from "./middlewares/securityMiddleware.js";
import accessHandler from "./middlewares/accessHandler.js";
import dbConnect from "./config/dbConnect.js";
configDotenv();
const app = express();
await dbConnect();
securityMiddleware(app);
app.set("trust proxy", true);
app.use(accessHandler);
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({ extended: true }));
app.use(cookieParser(process.env.COOKIE_SECRET));
app.use("/files", express.static("public"));
app.use("/api", api);
app.get("/", (req, res) => {
return res.status(200).json({
status: "success",
message: "Server is running successfully."
});
});
app.use(errorHandlerMiddleware);
// app.listen(process.env.PORT, () => {
// console.log(`Server running on port ${process.env.PORT}`);
// });
export default app;