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.

51 lines
1.6 KiB

  1. //used to append static content to result
  2. const includes = require('../includes/includes.js');
  3. /**
  4. * @author Jeffery Russell 10-30-18
  5. *
  6. * @type {{main: (function(*=, *): Promise)}}
  7. */
  8. module.exports=
  9. {
  10. serveStaticContent: function(request, result, filename, baseURL)
  11. {
  12. if (filename.includes(".svg") || filename.includes(".svg"))
  13. {
  14. includes.sendSVG(result, baseURL + filename);
  15. return true;
  16. }
  17. //handles image requests
  18. else if (filename.includes(".jpg") ||
  19. filename.includes(".png") || filename.includes(".ico"))
  20. {
  21. includes.sendImage(result, baseURL + filename);
  22. return true;
  23. }
  24. //css and font files
  25. else if (filename.includes(".woff2") || filename.includes(".css") ||
  26. filename.includes(".txt"))
  27. {
  28. includes.sendCSS(result, baseURL + filename);
  29. return true;
  30. }
  31. //scripts
  32. else if (filename.includes(".js"))
  33. {
  34. if(baseURL.includes("includes/") || baseURL.includes("blogContent"))
  35. {
  36. includes.sendJS(result, baseURL + filename);
  37. return true;
  38. }
  39. }
  40. //html
  41. else if (filename.includes(".html"))
  42. {
  43. includes.sendHTML(result, baseURL + filename);
  44. return true;
  45. }
  46. return false;
  47. }
  48. };