Skip to content

Commit

Permalink
Bump mongoose version and add server response to the root path
Browse files Browse the repository at this point in the history
  • Loading branch information
AntonellaMorittu authored and AntonellaMorittu committed May 13, 2024
1 parent 0966af5 commit 57219ae
Show file tree
Hide file tree
Showing 3 changed files with 132 additions and 78 deletions.
170 changes: 110 additions & 60 deletions backend/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion backend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
"express-list-endpoints": "^6.0.0",
"jsonwebtoken": "^9.0.2",
"mongodb": "^5.5.0",
"mongoose": "^7.2.1",
"mongoose": "^8.0.0",
"nodemon": "^2.0.15",
"passport": "^0.7.0",
"passport-google-oauth20": "^2.0.0"
Expand Down
38 changes: 21 additions & 17 deletions backend/server.js
Original file line number Diff line number Diff line change
@@ -1,30 +1,34 @@
// Import necessary libraries and modules
import express from "express"; // Import the Express.js framework
import cors from "cors"; // Import the CORS middleware
import dotenv from "dotenv"; // Import dotenv for environment variables
dotenv.config(); // Load environment variables from the .env file
import taskRoutes from "./routes/taskRoutes"; // Import custom task controlled-routes
import userRoutes from "./routes/userRoutes"; // Import custom user routes
import { connectDB } from "./config/db"; // Import database connection function (not used here)
import express from "express" // Import the Express.js framework
import cors from "cors" // Import the CORS middleware
import dotenv from "dotenv" // Import dotenv for environment variables
dotenv.config() // Load environment variables from the .env file
import taskRoutes from "./routes/taskRoutes" // Import custom task controlled-routes
import userRoutes from "./routes/userRoutes" // Import custom user routes
import { connectDB } from "./config/db" // Import database connection function (not used here)

// Defines the port the app will run on. Defaults to 8080, but can be overridden
const port = process.env.PORT; // Set the port number for the server
const app = express(); // Create an instance of the Express application
const port = process.env.PORT // Set the port number for the server
const app = express() // Create an instance of the Express application

// Add middlewares to enable cors and json body parsing
app.use(cors()); // Enable CORS (Cross-Origin Resource Sharing)
app.use(express.json()); // Parse incoming JSON data
app.use(express.urlencoded({ extended: false })); // Parse URL-encoded data
app.use(cors()) // Enable CORS (Cross-Origin Resource Sharing)
app.use(express.json()) // Parse incoming JSON data
app.use(express.urlencoded({ extended: false })) // Parse URL-encoded data

// Use the routes for handling API requests
// ROUTES - These routes USE controller functions ;)
app.use(taskRoutes); // Use the task-controlled routes for task-related requests
app.use(userRoutes); // Use the user-controlled routes for user-related requests
app.use(taskRoutes) // Use the task-controlled routes for task-related requests
app.use(userRoutes) // Use the user-controlled routes for user-related requests

// Connection to the database through Mongoose
connectDB();
connectDB()

app.get("/", (req, res) => {
res.send("Hello World!")
})

// Start the server and listen for incoming requests on the specified port
app.listen(port, () => {
console.log(`Server running on http://localhost:${port}`); // Display a message when the server is successfully started
});
console.log(`Server running on http://localhost:${port}`) // Display a message when the server is successfully started
})

0 comments on commit 57219ae

Please sign in to comment.