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.

48 lines
1.4 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. includes.sendJS(result, baseURL + filename);
  35. return true;
  36. }
  37. //html
  38. else if (filename.includes(".html"))
  39. {
  40. includes.sendHTML(result, baseURL + filename);
  41. return true;
  42. }
  43. return false;
  44. }
  45. };