-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
43 lines (37 loc) · 1.16 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
const express = require("express");
const cors = require("cors");
const connectDB = require("./config/ConnectDB");
require("dotenv").config();
const app = express();
// connect to Database
connectDB();
// middleware
app.use(express.json());
app.use(express.urlencoded({ extended: false }));
app.use(express.static("upload"));
app.use(
cors({
origin: ["https://ilink.onrender.com", "http://localhost:5173"],
methods: ["POST", "PUT", "DELETE", "GET"],
credentials: true,
allowedHeaders: ["access_token", "Content-type"],
exposedHeaders: ["access_token"],
})
);
// Routes
app.get("/api", (req, res) => {
res.status(200).send("Hello, welcome to ilinks server");
});
app.use("/api/auth", require("./src/routes/auth"));
app.use("/api/user", require("./src/routes/users"));
app.use("/api/ilinkData", require("./src/routes/ilink"));
app.use("/api/userIlink", require("./src/routes/userIlinkShow"));
app.use("/api/upload-files", require("./src/routes/uploadFile"));
//// verify email
app.post(
"/api/send-verify-email",
require("./src/controllers/sendVerifyEmail")
);
app.listen(process.env.PORT, () => {
console.log("server started", process.env.PORT);
});