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

const utils = require('../utils/utils.js');
const Promise = require('promise');
module.exports=
{
/**
* Method calls the admin widgets it correct order
*
* @param fileName
* @param request
* @return {*|Promise}
*/
main: function(fileName, request)
{
return new Promise(function(resolve, reject)
{
if(request.session && request.session.user)
{
utils.getPostData(request).then(function (postData)
{
Promise.all([require("../admin/newPost.js").main(postData),
require("../admin/addCategory.js").main(postData),
require("../admin/editPost.js").main(postData),
require("../admin/addDownload.js").main(postData)])
.then(function(content)
{
resolve(content.join(''));
}).catch(function(error)
{
reject(error);
});
});
}
else
{
//login page
console.log("login page");
require("../admin/login.js").main(request).then(function(html)
{
resolve(html);
}).catch(function(err)
{
console.log(err);
})
}
});
}
};