import express from "express"; import bodyParser from "body-parser"; import { mongoose } from "./database/mongoose.js"; import UserController from "./controllers/UserController.js"; import MatchController from "./controllers/MatchController.js"; import SportController from "./controllers/SportController.js"; import { userSession } from "./middleware/Authority.js"; const server = express(); const port = process.env.PORT || 3000; server.use(express.static("public")); // For all client files. if (process.env.NODE_ENV === "development") { mongoose.set("bufferCommands", false); // We want to know if there are connection issues immediately for development. Disables globally. } // Docs: https://www.npmjs.com/package/body-parser server.use(bodyParser.json()); server.use(bodyParser.urlencoded({ extended: true })); server.use(userSession); server.use("/user", UserController); server.use("/match", MatchController); server.use("/sport", SportController); server.listen(port, () => { console.log(`Server listening on port ${port}.`); });