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