Skip to content

Commit

Permalink
Update index.js
Browse files Browse the repository at this point in the history
  • Loading branch information
hardiksrivastavaa authored Aug 10, 2024
1 parent 15014c3 commit 55a30e4
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ const { v4: uuidv4 } = require("uuid");
const methodOverride = require("method-override");

// Use process.env.PORT for deployment environments
const port = process.env.PORT || 3000; // Default to 3000 for local development
const port = process.env.PORT;

app.use(express.urlencoded({ extended: true }));
app.use(methodOverride("_method"));
Expand Down Expand Up @@ -86,5 +86,9 @@ app.delete("/posts/:id", (req, res) => {
});

app.listen(port, () => {
if (!port) {
console.error("PORT environment variable is not set.");
process.exit(1);
}
console.log(`Listening on port ${port}`);
});

0 comments on commit 55a30e4

Please sign in to comment.