Personal blog written from scratch using Node.js, Bootstrap, and MySQL. https://jrtechs.net
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

41 lines
1.1 KiB

  1. /**
  2. * Main server file for the blog. This file is responsible for
  3. * creating the server and listening for clients. The main run
  4. * function parses the url and calls a sub module to make the
  5. * appropriate pages.
  6. */
  7. /** Stores the configuration for the server */
  8. const config = require('./utils/utils').getConfig();
  9. /** Port for the server to run on */
  10. const port = config.PORT;
  11. /** express app */
  12. const express = require("express");
  13. /** express app */
  14. const app = express();
  15. /** Used for gzip compression */
  16. const compression = require('compression');
  17. /**Updates the site map whenever the server is started */
  18. const map = require('./utils/generateSiteMap.js');
  19. map.main();
  20. /**session data for login */
  21. const session = require('express-session');
  22. /**Initializes sessions for login */
  23. app.use(session({ secret: config.SESSION_SECRET, cookie: { maxAge: 6000000 }}));
  24. const routes = require('./routes');
  25. app.use('/', routes);
  26. //enables gzip compression for the site
  27. app.use(compression());
  28. app.listen(port, () =>
  29. console.log(`App listening on port ${port}!`)
  30. );