-
Notifications
You must be signed in to change notification settings - Fork 335
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
biswa
committed
Oct 26, 2024
1 parent
c906526
commit 0705aaf
Showing
7 changed files
with
31 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,4 +14,4 @@ const connectDB = async () => { | |
} | ||
}; | ||
|
||
module.exports = connectDB; | ||
module.exports = connectDB; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,32 @@ | ||
// Import required modules | ||
const express = require('express'); | ||
const connectDB = require('./config/db'); | ||
const authRoutes = require('./routes/authRoutes'); | ||
const cookieParser = require('cookie-parser'); | ||
const config = require('./config/config'); // Import config | ||
const cors = require('cors'); // Import CORS | ||
const connectDB = require('./config/db'); // Database connection | ||
const authRoutes = require('./routes/authRoutes'); // Authentication routes | ||
const cookieParser = require('cookie-parser'); // Middleware for parsing cookies | ||
const config = require('./config/config'); // Config file for environment variables | ||
const cors = require('cors'); // Middleware for Cross-Origin Resource Sharing | ||
|
||
// Initialize express app | ||
const app = express(); | ||
|
||
// Connect to MongoDB | ||
connectDB(); | ||
|
||
// CORS configuration | ||
app.use(cors({ | ||
origin: 'http://your-frontend-domain.com', // Replace with your frontend URL | ||
credentials: true, // Allow credentials (cookies) to be sent | ||
origin: 'http://your-frontend-domain.com', // Replace with your frontend URL | ||
credentials: true // Allow credentials (cookies) to be sent with requests | ||
})); | ||
|
||
app.use(express.json()); | ||
app.use(cookieParser()); | ||
app.use('/api/auth', authRoutes); | ||
// Middleware | ||
app.use(express.json()); // Parse JSON bodies | ||
app.use(cookieParser()); // Enable cookie parsing | ||
|
||
// API routes | ||
app.use('/api/auth', authRoutes); // Route for authentication endpoints | ||
|
||
const PORT = config.port; // Use config for port | ||
// Server listening on configured port | ||
const PORT = config.port || 5000; // Use config for port, default to 5000 if undefined | ||
app.listen(PORT, () => { | ||
console.log(`Server running on port ${PORT}`); | ||
}); | ||
}); |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2965,4 +2965,4 @@ <h2>Exclusive Deals and Offers!</h2> | |
|
||
</body> | ||
|
||
</html> | ||
</html> |