index.js 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. const express = require("express");
  2. const hbs = require("hbs");
  3. const path = require("path");
  4. const { syncDataBase } = require("./Controllers/dataBase");
  5. const { createRouter } = require("./Routers/createDBRoute");
  6. const { dataBaseRouter } = require("./Routers/dataBaseRouter");
  7. const { deleteBaseRouter } = require("./Routers/deleteDBRouter");
  8. const { editRouter } = require("./Routers/editDBRouter");
  9. const { homeRouter } = require("./Routers/homeRouter");
  10. const app = express();
  11. const PORT = 3000;
  12. app.use(
  13. "/bootstrap",
  14. express.static(path.join(__dirname, "./node_modules/bootstrap"))
  15. );
  16. // app.use("/js", express.static(path.join(__dirname, "../Client/www")));
  17. app.use(
  18. "/jquery",
  19. express.static(path.join(__dirname, "./node_modules/jquery"))
  20. );
  21. app.use(express.json());
  22. app.set("view engine", "hbs");
  23. hbs.registerPartials(path.join(__dirname + "/views/partials"));
  24. //API
  25. app.use("/", homeRouter);
  26. app.use("/database", dataBaseRouter);
  27. app.use("/database/edit", editRouter);
  28. app.use("/database/create", createRouter);
  29. app.use("/database/delete", deleteBaseRouter);
  30. app.use(function (req, res) {
  31. res.status(404).render("404.hbs");
  32. });
  33. app.listen(PORT, () => console.log(`My port is ${PORT}`));
  34. syncDataBase();
  35. module.exports = {
  36. app,
  37. PORT,
  38. };