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.

47 lines
1.3 KiB

  1. //sending static content
  2. const includes = require('../includes/includes.js');
  3. //used to append static content to result
  4. const contentLoader = require('../includes/staticContentServer.js');
  5. /**
  6. * @author Jeffery Russell 11-3-18
  7. *
  8. * @type {{main: (function(*=, *): Promise)}}
  9. */
  10. module.exports=
  11. {
  12. /**
  13. * Calls posts and sidebar modules to render blog contents in order
  14. *
  15. * @param requestURL
  16. * @returns {Promise|*}
  17. */
  18. main: function(request, result, filename)
  19. {
  20. if(contentLoader.serveStaticContent(request, result, filename, ""))
  21. {
  22. //do nothing
  23. }
  24. else
  25. {
  26. result.writeHead(200, {'Content-Type': 'text/html'});
  27. const file = "../admin/admin.js";
  28. Promise.all([includes.printAdminHeader(),
  29. require(file).main(request),
  30. includes.printFooter()]).then(function(content)
  31. {
  32. result.write(content.join(''));
  33. result.end();
  34. }).catch(function(err)
  35. {
  36. console.log(err);
  37. throw err;
  38. });
  39. }
  40. }
  41. };