UNPKG

mnglab

Version:

Dead simple REST micro-framework with modular routing, API key, rate limiting, full HTTP response handling, dev tools, JSON DB, file helpers, endpoint stats, and professional developer experience.

34 lines (28 loc) 851 B
#!/usr/bin/env node const fs = require('fs'); const path = require('path'); const { spawn } = require('child_process'); const chalk = require('chalk'); let server; let debounce; function run() { if (server) server.kill(); console.clear(); console.log(chalk.cyanBright('[MngLab Dev] Reloading...')); server = spawn('node', ['index.js'], { stdio: 'inherit' }); } function watch(dir) { fs.readdirSync(dir).forEach(file => { const fullPath = path.join(dir, file); if (fs.statSync(fullPath).isDirectory()) return watch(fullPath); if (file.endsWith('.js') || file.endsWith('.json')) { fs.watchFile(fullPath, { interval: 200 }, () => { clearTimeout(debounce); debounce = setTimeout(run, 300); }); } }); } console.log(chalk.greenBright('🚀 MngLab Dev Tool Active')); run(); watch(process.cwd());