Refactor code structure for improved readability and maintainability

This commit is contained in:
Shni
2025-10-15 09:54:32 -05:00
parent 0ab59bf6a8
commit 2a67d249fb
8 changed files with 133 additions and 16 deletions

16
scripts/test_render.js Normal file
View File

@@ -0,0 +1,16 @@
(async()=>{
try{
const ejs=require('ejs'), path=require('path');
const viewsDir=path.join(process.cwd(),'src','server','views');
const pageFile = path.join(viewsDir,'pages','dashboard.ejs');
const layoutFile = path.join(viewsDir,'layouts','layout.ejs');
const locals={ appName:'amayo', user:{username:'test',id:'1',avatar:''}, guilds:[], useDashboardNav:false, version:'x', selectedGuild: null, title:'Dashboard test', hideNavbar:false };
console.log('render page');
const pageBody = await ejs.renderFile(pageFile, locals, {async:true, views:[viewsDir]});
console.log('pageBody type:', typeof pageBody);
const html = await ejs.renderFile(layoutFile, {...locals, body: pageBody, dashboardNav:null, navbar:null, title: locals.title, useDashboardNav: locals.useDashboardNav}, {async:true, views:[viewsDir]});
console.log('html length', html.length);
if (html.indexOf('[object Promise]')!==-1){ console.log('FOUND at', html.indexOf('[object Promise]')); console.log(html.slice(0,200)); process.exit(3);}
console.log('OK NO PROMISE'); process.exit(0);
}catch(e){ console.error('ERR',e); process.exit(2);}
})();