UNPKG

legendaryjs

Version:

LegendaryJS – The ultimate backend framework for speed, power, and simplicity.

26 lines (19 loc) 647 B
const fs = require('fs'); const path = require('path'); function loadLogic(dir = 'logic') { const logic = {}; const fullPath = path.join(process.cwd(), dir); if (!fs.existsSync(fullPath)) return logic; const files = fs.readdirSync(fullPath).filter(f => f.endsWith('.js')); for (const file of files) { const name = file.replace('.js', ''); try { logic[name] = require(path.join(fullPath, file)); console.log(`🧠 Loaded logic: ${name}`); } catch (err) { console.error(`❌ Failed to load logic file: ${file}`, err); } } return logic; } module.exports = { loadLogic };