-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
64 lines (51 loc) · 1.35 KB
/
index.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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
import express from "express";
import cors from "cors";
import dotenv from "dotenv";
import mongoose from "mongoose";
import cookieParser from "cookie-parser";
import userRoutes from "./routes/userRoutes.js"
import connectionRoutes from "./routes/connectionRoutes.js"
import workFlowRoutes from "./routes/workFlowRoutes.js"
import uploadRoutes from "./routes/uploadRoutes.js"
dotenv.config();
const app = express();
mongoose
.connect(process.env.MONGO_URI)
.then(console.log("Connected to MongoDB"))
.catch((err) => console.log(err));
// Using Middlewares
app.use(
cors({
origin: process.env.FRONTEND_URL,
credentials: true,
methods: ["GET", "POST", "PUT", "DELETE"],
})
);
app.set("trust proxy", 1);
app.use(
express.urlencoded({
extended: true,
})
);
app.use(express.json());
app.use(cookieParser());
app.use('/uploads', express.static('uploads'));
// Routes
app.use('/api', userRoutes);
app.use('/connection',connectionRoutes);
app.use('/workflows',workFlowRoutes);
app.use('/upload',uploadRoutes);
app.get("/", (req, res) => {
res.json({ do: "SMILE", start: "Developing something great & keep :) :)" });
});
app
.listen(process.env.PORT, () => {
console.log(`listening to port ${process.env.PORT}`);
})
.on("error", (err) => {
console.log(err);
process.exit();
})
.on("close", () => {
process.exit();
});