-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
34 lines (27 loc) · 797 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
import dotenv from "dotenv";
import cors from "cors";
import cookieParser from "cookie-parser";
import mongoose from "mongoose";
import express from "express";
import authRoutes from "./routes/AuthRoutes.js";
dotenv.config();
const app = express();
const port = process.env.PORT || 3001;
const databaseURL = process.env.DATABASE_URL;
app.use(
cors({
origin: [process.env.ORIGIN],
methods: ["GET", "POST", "PUT", "DELETE", "PATCH"],
credentials: true,
})
);
app.use(cookieParser());
app.use(express.json());
app.use("/api/auth", authRoutes);
const server = app.listen(port, () => {
console.log(`Server is running at http://localhost:${port}`);
});
mongoose
.connect(databaseURL)
.then(() => console.log("DB Connection Successful"))
.catch((err) => console.log(err));