// ========================================= // ANTIGRAVITY CORE SAAS API v4 ENTERPRISE // ========================================= import express from 'express'; import cors from 'cors'; import fs from 'fs'; import path from 'path'; import axios from 'axios'; import jwt from 'jsonwebtoken'; import crypto from 'crypto'; import { exec } from 'child_process'; import { fileURLToPath } from 'url'; const __filename = fileURLToPath(import.meta.url); const __dirname = path.dirname(__filename); const app = express(); app.use(cors()); app.use(express.json({ limit:'50mb' })); app.use(express.urlencoded({ extended:true })); app.use( express.static( path.join(__dirname,'public') ) ); // ========================================= // CONFIG // ========================================= const PORT = 4000; const JWT_SECRET = 'ANTIGRAVITY_JWT_ENTERPRISE_2026'; const MASTER_API_KEY = '8fK29xA_ANTIGRAVITY_CORE_SECURE_2026_x9PqL'; const DB_PATH = path.join(__dirname,'database.json'); const LOG_PATH = path.join(__dirname,'logs.txt'); // ========================================= // CREATE FILES // ========================================= if(!fs.existsSync(DB_PATH)){ fs.writeFileSync( DB_PATH, JSON.stringify({ sites:{}, users:{}, analytics:{} },null,2) ); } if(!fs.existsSync(LOG_PATH)){ fs.writeFileSync(LOG_PATH,''); } // ========================================= // DATABASE // ========================================= function readDB(){ return JSON.parse( fs.readFileSync(DB_PATH,'utf-8') ); } function saveDB(data){ fs.writeFileSync( DB_PATH, JSON.stringify(data,null,2) ); } // ========================================= // LOGGER // ========================================= function addLog(message){ const time = new Date().toISOString(); const finalLog = `[${time}] ${message}\n`; fs.appendFileSync( LOG_PATH, finalLog ); console.log(finalLog); } // ========================================= // HELPERS // ========================================= function generateSiteToken(){ return crypto .randomBytes(32) .toString('hex'); } function generateJWT(payload){ return jwt.sign( payload, JWT_SECRET, { expiresIn:'30d' } ); } // ========================================= // AUTH MIDDLEWARE // ========================================= function validateApiKey(req,res,next){ const apiKey = req.headers['api_key']; if(apiKey !== MASTER_API_KEY){ addLog( '[SECURITY] INVALID API KEY' ); return res.status(401).json({ error:'INVALID_API_KEY' }); } next(); } // ========================================= // HEALTH // ========================================= app.get('/health',(req,res)=>{ res.json({ status:'ONLINE', system:'ANTIGRAVITY CORE', version:'4.0 ENTERPRISE', uptime:process.uptime(), memory:process.memoryUsage(), timestamp:new Date() }); }); // ========================================= // ROOT // ========================================= app.get('/',(req,res)=>{ res.redirect('/dashboard.html'); }); // ========================================= // LOGIN // ========================================= app.post('/login',(req,res)=>{ const { username, password } = req.body; if( username === 'admin' && password === 'antigravity' ){ const token = generateJWT({ username }); return res.json({ success:true, token }); } res.status(401).json({ success:false }); }); // ========================================= // REGISTER SITE // ========================================= app.post( '/register-site', validateApiKey, (req,res)=>{ try{ const db = readDB(); const { site_url, site_name } = req.body; const token = generateSiteToken(); db.sites[site_url] = { site_name, site_url, token, created_at: new Date().toISOString(), status:'ONLINE', post_count:0, wp_version:'N/A', last_seen: new Date().toISOString() }; saveDB(db); addLog( `[REGISTER] ${site_url}` ); res.json({ success:true, token }); }catch(err){ res.status(500).json({ error:'REGISTER_FAILED' }); } } ); // ========================================= // PULSE // ========================================= app.post( '/pulse', validateApiKey, (req,res)=>{ try{ const stats = req.body; const db = readDB(); db.sites[ stats.site_url ] = { ...stats, last_seen: new Date().toISOString(), status:'ONLINE' }; saveDB(db); addLog( `[PULSE] ${stats.site_url}` ); res.json({ status:'ONLINE' }); }catch(err){ addLog( `[ERROR] PULSE FAILURE` ); res.status(500).json({ error:'PULSE_FAILED' }); } } ); // ========================================= // SITES // ========================================= app.get('/sites',(req,res)=>{ try{ const db = readDB(); res.json(db.sites); }catch(err){ res.json({}); } }); // ========================================= // ANALYTICS // ========================================= app.get('/analytics',(req,res)=>{ const db = readDB(); const sites = Object.keys( db.sites ).length; let posts = 0; for( const site in db.sites ){ posts += db.sites[site] .post_count || 0; } res.json({ total_sites:sites, total_posts:posts, ai_agents:12, revenue:'$4,820', autonomous:true }); }); // ========================================= // AGENTS // ========================================= app.get('/agents',(req,res)=>{ res.json({ running:12, workers:32, autonomous:true, empire_mode:true, ai_brain:'ONLINE' }); }); // ========================================= // LOGS // ========================================= app.get('/logs',(req,res)=>{ try{ const logs = fs.readFileSync( LOG_PATH, 'utf-8' ); res.send(logs); }catch(err){ res.send( 'NO LOGS' ); } }); // ========================================= // START ORCHESTRATOR // ========================================= app.post('/run-empire',(req,res)=>{ addLog( '[SYSTEM] STARTING EMPIRE' ); const empirePath = path.join( __dirname, '..', 'orchestrator_empire.py' ); exec( `python "${empirePath}"`, ( err, stdout, stderr )=>{ if(err){ addLog( `[ERROR] ${err.message}` ); return res .status(500) .send( err.message ); } addLog( '[SUCCESS] ORCHESTRATOR ONLINE' ); res.send( stdout || 'EMPIRE STARTED' ); } ); }); // ========================================= // PUSH GLOBAL CSS // ========================================= app.post('/push-styles',async(req,res)=>{ try{ const { css } = req.body; const db = readDB(); const results = []; for( const url in db.sites ){ try{ await axios.post( `${url}/wp-json/antigravity/v1/update-styles`, { css }, { headers:{ api_key: MASTER_API_KEY } } ); results.push({ url, status:'SUCCESS' }); }catch(err){ results.push({ url, status:'FAILED' }); } } addLog( '[STYLE] PATCH APPLIED' ); res.json({ status:'PATCH_APPLIED', results }); }catch(err){ res.status(500).json({ error:'STYLE_FAILED' }); } }); // ========================================= // BROADCAST // ========================================= app.post('/broadcast',(req,res)=>{ const { message } = req.body; addLog( `[BROADCAST] ${message}` ); res.json({ status:'BROADCAST_SENT' }); }); // ========================================= // AI AUTO HEAL // ========================================= setInterval(()=>{ addLog( '[AI] SELF HEAL CHECK' ); },60000); // ========================================= // SERVER // ========================================= app.listen(PORT,()=>{ console.log(` ========================================= ANTIGRAVITY CORE ONLINE ========================================= Dashboard: http://localhost:${PORT}/dashboard.html Health: http://localhost:${PORT}/health Analytics: http://localhost:${PORT}/analytics ========================================= `); }); https://travelorbit.com.br/post-sitemap1.xml 2026-04-29T18:30:30+00:00 https://travelorbit.com.br/post-sitemap2.xml 2026-04-29T18:30:28+00:00 https://travelorbit.com.br/page-sitemap.xml 2026-04-29T18:30:01+00:00 https://travelorbit.com.br/category-sitemap.xml 2026-04-29T18:30:30+00:00