Skip to content

Commit

Permalink
Merge pull request #2 from Pranavtej/vamsi
Browse files Browse the repository at this point in the history
ECARD-3
  • Loading branch information
Pranavtej authored Dec 2, 2023
2 parents ea48e2e + 17a71be commit 9199756
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 23 deletions.
41 changes: 20 additions & 21 deletions connection.js
Original file line number Diff line number Diff line change
@@ -1,28 +1,27 @@
// const mongoose = require('mongoose');
// const dotenv = require('dotenv');
const mongoose = require('mongoose');
const dotenv = require('dotenv');

// // Load the environment variables from .env file
// dotenv.config();
// Load the environment variables from .env file
dotenv.config();

// // MongoDB connection URL
// const mongoUrl = `mongodb://${process.env.DB_HOST}:${process.env.DB_PORT}/${process.env.DB_DATABASE}`;
// MongoDB connection URL
const mongoUrl = `mongodb+srv://${process.env.DB_USERNAME}:${process.env.DB_PASSWORD}@${process.env.DB_HOST}/${process.env.DB_DATABASE}?retryWrites=true&w=majority`;

// // Set up MongoDB connection
// mongoose.connect(mongoUrl, {
// useNewUrlParser: true,
// useUnifiedTopology: true,
// useCreateIndex: true,
// });
// Set up MongoDB connection
mongoose.connect(mongoUrl, {
useNewUrlParser: true,
useUnifiedTopology: true,
});

// const db = mongoose.connection;
const db = mongoose.connection;

// db.on('error', (error) => {
// console.error('MongoDB connection error:', error);
// process.exit(1); // Exit process on connection error
// });
db.on('error', (error) => {
console.error('MongoDB connection error:', error);
process.exit(1); // Exit process on connection error
});

// db.once('open', () => {
// console.log('Connected to MongoDB');
// });
db.once('open', () => {
console.log('Connected to MongoDB');
});

// module.exports = mongoose;
module.exports = mongoose;
2 changes: 1 addition & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,6 @@ app.get("/",(req,res)=>{



app.listen(3000, function () {
app.listen(8000, function () {
console.log('Server started at port 3000');
})
2 changes: 1 addition & 1 deletion views/index.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@
<title>eCardify</title>
</head>
<body>
<h1>eCardify</h1>
<h1>Welcome eCardify </h1>
</body>
</html>

0 comments on commit 9199756

Please sign in to comment.