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.
 
 

61 lines
1.8 KiB

//used to append static content to result
const includes = require('../includes/includes.js');
/**
* @author Jeffery Russell 10-30-18
*
* @type {{main: (function(*=, *): Promise)}}
*/
module.exports=
{
serveStaticContent: function(request, result, filename, baseURL)
{
fullPath = baseURL + filename;
if (filename.includes(".svg") || filename.includes(".svg"))
{
includes.sendSVG(result, fullPath);
return true;
}
//handles image requests
else if (filename.includes(".jpg") ||
filename.includes(".png") || filename.includes(".ico"))
{
includes.sendImage(result, fullPath);
return true;
}
//css and font files
else if (filename.includes(".woff2") || filename.includes(".css") ||
filename.includes(".txt"))
{
includes.sendCSS(result, fullPath);
return true;
}
else if (filename.includes(".json"))
{
if(fullPath.includes("includes/") || fullPath.includes("blogContent"))
{
includes.sendHTML(result, fullPath);
return true;
}
}
//scripts
else if (filename.includes(".js"))
{
if(fullPath.includes("includes/") || fullPath.includes("blogContent"))
{
includes.sendJS(result, fullPath);
return true;
}
}
//html
else if (filename.includes(".html"))
{
includes.sendHTML(result, fullPath);
return true;
}
return false;
}
};