-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.js
41 lines (34 loc) · 1012 Bytes
/
app.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
require("dotenv").config();
const cors = require("cors");
const path = require("path");
const express = require("express");
const { default: mongoose } = require("mongoose");
const userRoute = require("./routes/user");
const adminRoute = require("./routes/admin");
const useragent = require("express-useragent");
mongoose.set("strictQuery", false);
const app = express();
app.use(express.json());
app.use(
cors({
origin: ["http://localhost:3000", "https://karaoya-frontend.vercel.app"],
methods: ["GET", "POST", "PUT", "PATCH", "DELETE"],
credentials: true,
preflightContinue: false,
optionsSuccessStatus: 204,
})
);
app.use(useragent.express());
app.use("/user", userRoute);
app.use("/admin", adminRoute);
mongoose
.connect(process.env.MONGO_URL)
.then(() => {
app.listen(process.env.PORT || 3000, () => {
console.log("connected to db & listening on port:", process.env.PORT);
});
})
.catch((err) => {
console.log(err);
});
console.log("Hello World");