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.

49 lines
1.5 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. console.log(filename);
  13. if (filename.includes(".svg") || filename.includes(".svg"))
  14. {
  15. includes.sendSVG(result, baseURL + filename);
  16. return true;
  17. }
  18. //handles image requests
  19. else if (filename.includes(".jpg") ||
  20. filename.includes(".png") || filename.includes(".ico"))
  21. {
  22. includes.sendImage(result, baseURL + filename);
  23. return true;
  24. }
  25. //css and font files
  26. else if (filename.includes(".woff2") || filename.includes(".css") ||
  27. filename.includes(".txt"))
  28. {
  29. includes.sendCSS(result, baseURL + filename);
  30. return true;
  31. }
  32. //scripts
  33. else if (filename.includes(".js"))
  34. {
  35. includes.sendJS(result, baseURL + filename);
  36. return true;
  37. }
  38. //html
  39. else if (filename.includes(".html"))
  40. {
  41. includes.sendHTML(result, baseURL + filename);
  42. return true;
  43. }
  44. return false;
  45. }
  46. };