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.

59 lines
1.8 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. fullPath = baseURL + filename;
  13. if (filename.includes(".svg") || filename.includes(".svg"))
  14. {
  15. includes.sendSVG(result, fullPath);
  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, fullPath);
  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, fullPath);
  30. return true;
  31. }
  32. else if (filename.includes(".json"))
  33. {
  34. if(fullPath.includes("includes/") || fullPath.includes("blogContent"))
  35. {
  36. includes.sendHTML(result, fullPath);
  37. return true;
  38. }
  39. }
  40. //scripts
  41. else if (filename.includes(".js"))
  42. {
  43. if(fullPath.includes("includes/") || fullPath.includes("blogContent"))
  44. {
  45. includes.sendJS(result, fullPath);
  46. return true;
  47. }
  48. }
  49. //html
  50. else if (filename.includes(".html"))
  51. {
  52. includes.sendHTML(result, fullPath);
  53. return true;
  54. }
  55. return false;
  56. }
  57. };