-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathindex.js
37 lines (30 loc) · 874 Bytes
/
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
const express = require("express");
const userRoutes = require("./routes/usercontroller");
const cors = require("cors");
const cors = require("cors");
const bodyParser = require("body-parser");
const cookieParser = require("cookie-parser");
require("dotenv").config({ path: "../.env" });
const app = express();
app.use(express.json());
app.use(bodyParser.json());
// app.use(cors({
// origin:"http://localhost:3000",
// //methods: ["GET", "POST", "PUT", "DELETE", "OPTIONS"],
// credentials: true
// }))
app.use(cookieParser());
app.use(
cors({
origin: "http://localhost:3000",
methods: ["GET", "POST", "PUT", "DELETE", "OPTIONS"],
credentials: true,
})
);
const connectDB = require("./config/db.js");
connectDB();
app.use("/api", userRoutes);
const PORT = process.env.PORT;
app.listen(PORT, () => {
console.log("Running at", PORT);
});