forked from opencodeiiita/FandomFusion-Backend
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.js
26 lines (25 loc) · 706 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
import dotenv from "dotenv";
import express from "express";
import cors from "cors";
import mongoose from "mongoose";
import dbURL from "./src/config/db.config.js";
dotenv.config();
const app = express();
app.use(express.json());
app.use(express.urlencoded({ extended: true }));
app.use(cors());
app.get("/", (req, res) => {
res.send("Hello World");
});
const PORT = process.env.PORT || 4000;
app.listen(PORT, () => {
console.log(`Server is listening on port ${PORT}! 🚀`);
});
mongoose.connect(dbURL)
.then(() => {
console.log("Successfully connected to MongoDB Atlas");
})
.catch(err => {
console.log("Could not connect to MongoDB Atlas. Exiting now...", err);
process.exit();
});