import express from "express"; import cors from "cors"; const app = express(); const PORT = process.env.PORT; app.set("view engine", "ejs"); app.use(cors()); app.use(express.json()); app.use(express.urlencoded({ extended: true })); app.get("/", (req, res) => { res.render("index"); }); app.listen(PORT, () => { console.log(`Server is running on http://localhost:${PORT}`); }); // error handling code app.use((err, req, res, next) => { console.error(err.stack); res.status(500).send("Something broke!"); });