Skip to content

Commit

Permalink
Adding new file for database
Browse files Browse the repository at this point in the history
  • Loading branch information
Frnn4268 committed Jun 9, 2024
1 parent f768161 commit 1a165bb
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 14 deletions.
15 changes: 15 additions & 0 deletions server/config/databaseConnection.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
const mongoose = require('mongoose')

mongoose.set('strictQuery', true);

mongoose.connect(process.env.MONGO_URL, {
useNewUrlParser: true,
useUnifiedTopology: true,
})
.then(() => {
console.log("Database connetion Successfull");
})
.catch((err) => {
console.log(err.message);
});

15 changes: 1 addition & 14 deletions server/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,24 +7,11 @@ const app = express();
const socket = require("socket.io");

require("dotenv").config();
require('./config/databaseConnection')

app.use(cors());
app.use(express.json());

mongoose.set('strictQuery', true);

mongoose
.connect(process.env.MONGO_URL, {
useNewUrlParser: true,
useUnifiedTopology: true,
})
.then(() => {
console.log("DB Connetion Successfull");
})
.catch((err) => {
console.log(err.message);
});

app.get("/ping", (_req, res) => {
return res.json({ msg: "Ping Successful" });
});
Expand Down

0 comments on commit 1a165bb

Please sign in to comment.