UNPKG

legendaryjs

Version:

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

42 lines (34 loc) 1.37 kB
const express = require('express'); const path = require('path'); const fs = require('fs'); function setupStudio(app, io) { const studioPath = path.join(process.cwd(), 'studio'); app.use('/legendary-studio', express.static(studioPath)); app.get('/gui/routes', (req, res) => { const routeFile = path.join(process.cwd(), 'routes/api.v1.json'); if (!fs.existsSync(routeFile)) return res.json({ routes: [] }); res.json(JSON.parse(fs.readFileSync(routeFile))); }); app.post('/gui/routes', (req, res) => { const file = path.join(process.cwd(), 'routes/api.v1.json'); fs.writeFileSync(file, JSON.stringify(req.body, null, 2)); res.json({ success: true }); }); app.post('/gui/config', (req, res) => { const configPath = path.join(process.cwd(), 'legendary.config.js'); const content = `module.exports = ${JSON.stringify(req.body, null, 2)};`; fs.writeFileSync(configPath, content); res.json({ success: true }); }); io.of('/dashboard').on('connection', (socket) => { console.log('📊 Studio connected'); setInterval(() => { socket.emit('stats', { memory: process.memoryUsage(), uptime: process.uptime(), }); }, 2000); }); console.log('🧠 Legendary Studio available at /legendary-studio'); } module.exports = { setupStudio };