Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ECARD-3 #2

Merged
merged 1 commit into from
Dec 2, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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>
Loading