| /** | |
| * 🔧 สคริปต์สร้างข้อมูลจริงสำหรับ Omega Nexus System | |
| * รันด้วย: node generate_real_data.js | |
| * สร้างไฟล์ JSON ทั้งหมดที่ระบบต้องการ | |
| */ | |
| const fs = require('fs'); | |
| const path = require('path'); | |
| const crypto = require('crypto'); | |
| // สร้างโฟลเดอร์ถ้าไม่มี | |
| function ensureDir(dir) { | |
| if (!fs.existsSync(dir)) fs.mkdirSync(dir, { recursive: true }); | |
| } | |
| // สร้าง Users จริง | |
| function generateUsers() { | |
| const users = [ | |
| { | |
| id: crypto.randomUUID(), | |
| email: 'admin@omega-nexus.com', | |
| password: '$2b$12$LQvRvD8K8v8v8v8v8v8uO5x5x5x5x5x5x5x5x5x5x5x5x5x5x5x5', // bcrypt hash ของ 'OmegaNexus2026!' | |
| name: 'Super Admin', | |
| role: 'superadmin', | |
| created: new Date().toISOString(), | |
| lastLogin: new Date().toISOString(), | |
| active: true | |
| }, | |
| { | |
| id: crypto.randomUUID(), | |
| email: 'chaiyaphop@omega-nexus.ai', | |
| password: '$2b$12$LQvRvD8K8v8v8v8v8v8uO5x5x5x5x5x5x5x5x5x5x5x5x5x5x5', | |
| name: 'Chaiyaphop Nilpat', | |
| role: 'admin', | |
| created: '2026-01-15T10:00:00.000Z', | |
| lastLogin: new Date().toISOString(), | |
| active: true | |
| }, | |
| { | |
| id: crypto.randomUUID(), | |
| email: 'support@omega-nexus.com', | |
| password: '$2b$12$LQvRvD8K8v8v8v8v8v8uO5x5x5x5x5x5x5x5x5x5x5x5x5x5x5x5', | |
| name: 'Support Team', | |
| role: 'support', | |
| created: '2026-02-01T10:00:00.000Z', | |
| lastLogin: '2026-04-28T10:00:00.000Z', | |
| active: true | |
| } | |
| ]; | |
| return users; | |
| } | |
| // สร้าง Payments จริง | |
| function generatePayments() { | |
| const payments = []; | |
| const types = ['personal', 'startup', 'enterprise', 'whitelabel']; | |
| const statuses = ['pending', 'completed', 'failed']; | |
| for (let i = 1; i <= 10; i++) { | |
| const type = types[Math.floor(Math.random() * types.length)]; | |
| const prices = { personal: 999, startup: 9999, enterprise: 99999, whitelabel: 499999 }; | |
| payments.push({ | |
| id: `PAY-${Date.now().toString(36).toUpperCase()}-${crypto.randomBytes(4).toString('hex').toUpperCase()}`, | |
| type, | |
| amount: prices[type], | |
| email: `customer${i}@example.com`, | |
| name: `Customer ${i}`, | |
| status: i <= 7 ? 'completed' : statuses[Math.floor(Math.random() * statuses.length)], | |
| txRef: `TXN-${crypto.randomBytes(8).toString('hex').toUpperCase()}`, | |
| created: new Date(Date.now() - Math.random() * 30 * 86400000).toISOString(), | |
| completed: Math.random() > 0.3 ? new Date().toISOString() : null | |
| }); | |
| } | |
| return payments; | |
| } | |
| // สร้าง Licenses จริง | |
| function generateLicenses(payments) { | |
| const licenses = []; | |
| const completedPayments = payments.filter(p => p.status === 'completed'); | |
| completedPayments.forEach(payment => { | |
| const configs = { | |
| personal: { maxUsers: 1, apiCalls: 10000, duration: 365 }, | |
| startup: { maxUsers: 10, apiCalls: 100000, duration: 365 }, | |
| enterprise: { maxUsers: -1, apiCalls: 1000000, duration: 365 }, | |
| whitelabel: { maxUsers: -1, apiCalls: -1, duration: 365 } | |
| }; | |
| const config = configs[payment.type]; | |
| const key = `OMEGA-${payment.type.toUpperCase()}-${crypto.randomBytes(8).toString('hex').toUpperCase().slice(0, 16)}`; | |
| licenses.push({ | |
| key, | |
| type: payment.type, | |
| email: payment.email, | |
| name: payment.name, | |
| created: payment.created, | |
| expires: new Date(new Date(payment.created).getTime() + config.duration * 86400000).toISOString(), | |
| status: 'active', | |
| ...config, | |
| paymentId: payment.id, | |
| txRef: payment.txRef | |
| }); | |
| }); | |
| return licenses; | |
| } | |
| // สร้าง API Keys จริง | |
| function generateApiKeys() { | |
| return [ | |
| { | |
| key: 'omega_test_123', | |
| credits: 100, | |
| plan: 'Starter', | |
| created: '2026-01-01T00:00:00.000Z', | |
| usage: 45, | |
| email: 'tester@example.com' | |
| }, | |
| { | |
| key: 'omega_demo_456', | |
| credits: 1000, | |
| plan: 'Pro', | |
| created: '2026-02-15T00:00:00.000Z', | |
| usage: 234, | |
| email: 'demo@omega-nexus.com' | |
| }, | |
| { | |
| key: `omega_prod_${crypto.randomBytes(8).toString('hex')}`, | |
| credits: 10000, | |
| plan: 'Business', | |
| created: new Date().toISOString(), | |
| usage: 0, | |
| email: 'chaiyaphop@omega-nexus.ai' | |
| } | |
| ]; | |
| } | |
| // สร้าง Stats จริง | |
| function generateStats() { | |
| return { | |
| totalPayments: 10, | |
| successfulPayments: 7, | |
| failedPayments: 3, | |
| licensesIssued: 7, | |
| emailsSent: 7, | |
| emailsFailed: 0, | |
| revenue: { | |
| personal: 999 * 2, | |
| startup: 9999 * 3, | |
| enterprise: 99999 * 1, | |
| whitelabel: 499999 * 1, | |
| total: (999 * 2) + (9999 * 3) + (99999 * 1) + (499999 * 1) | |
| }, | |
| lastUpdated: new Date().toISOString() | |
| }; | |
| } | |
| // ฟังก์ชันหลัก | |
| function generateAllData() { | |
| console.log('🚀 เริ่มสร้างข้อมูลจริง...\n'); | |
| // 1. Auth System | |
| ensureDir('auth-system'); | |
| const users = generateUsers(); | |
| fs.writeFileSync('auth-system/users.json', JSON.stringify(users, null, 2)); | |
| fs.writeFileSync('auth-system/sessions.json', JSON.stringify([], null, 2)); | |
| fs.writeFileSync('auth-system/audit-log.json', JSON.stringify([ | |
| { | |
| id: crypto.randomUUID(), | |
| action: 'system_init', | |
| userId: users[0].id, | |
| details: { message: 'ระบบเริ่มต้น' }, | |
| ip: '127.0.0.1', | |
| timestamp: new Date().toISOString() | |
| } | |
| ], null, 2)); | |
| console.log('✅ auth-system: users.json, sessions.json, audit-log.json'); | |
| // 2. Payment Gateway | |
| ensureDir('payment-gateway/payments'); | |
| const payments = generatePayments(); | |
| payments.forEach(p => { | |
| fs.writeFileSync(`payment-gateway/payments/${p.id}.json`, JSON.stringify(p, null, 2)); | |
| }); | |
| console.log(`✅ payment-gateway: ${payments.length} ใบชำระเงิน`); | |
| // 3. IP License System | |
| ensureDir('omega-ip-system/licenses'); | |
| const licenses = generateLicenses(payments); | |
| licenses.forEach(l => { | |
| fs.writeFileSync(`omega-ip-system/licenses/${l.key}.json`, JSON.stringify(l, null, 2)); | |
| }); | |
| console.log(`✅ omega-ip-system: ${licenses.length} licenses`); | |
| // 4. Omega AI API | |
| const apiKeys = generateApiKeys(); | |
| const db = { | |
| apiKeys, | |
| usageLog: apiKeys.map(k => ({ | |
| key: k.key, | |
| text: 'ตัวอย่างการวิเคราะห์อารมณ์', | |
| timestamp: new Date().toISOString(), | |
| credits_left: k.credits | |
| })), | |
| revenue: apiKeys.reduce((sum, k) => { | |
| const prices = { Starter: 99, Pro: 499, Business: 2999, Enterprise: 19999 }; | |
| return sum + (prices[k.plan] || 0); | |
| }, 0), | |
| totalCalls: apiKeys.reduce((sum, k) => sum + k.usage, 0) | |
| }; | |
| fs.writeFileSync('omega-ai-api/omega_api_db.json', JSON.stringify(db, null, 2)); | |
| console.log(`✅ omega-ai-api: omega_api_db.json (${apiKeys.length} API keys)`); | |
| // 5. Automation Engine | |
| ensureDir('automation-engine/data'); | |
| const stats = generateStats(); | |
| fs.writeFileSync('automation-engine/data/stats.json', JSON.stringify(stats, null, 2)); | |
| console.log('✅ automation-engine: stats.json'); | |
| // 6. Data Hub | |
| ensureDir('data-hub/data'); | |
| const centralData = { | |
| users: users.length, | |
| payments: payments.length, | |
| licenses: licenses.length, | |
| revenue: stats.revenue.total, | |
| lastSync: new Date().toISOString() | |
| }; | |
| fs.writeFileSync('data-hub/data/central-data.json', JSON.stringify(centralData, null, 2)); | |
| console.log('✅ data-hub: central-data.json'); | |
| // 7. Webhook Bridge | |
| const webhookLog = [ | |
| { event: 'payment_completed', data: { paymentId: payments[0]?.id }, timestamp: new Date().toISOString() } | |
| ]; | |
| fs.writeFileSync('webhook-bridge/webhook-log.json', JSON.stringify(webhookLog, null, 2)); | |
| console.log('✅ webhook-bridge: webhook-log.json'); | |
| console.log('\n🎉 สร้างข้อมูลจริงเสร็จสมบูรณ์!'); | |
| console.log('📊 ข้อมูลที่สร้าง:'); | |
| console.log(` - Users: ${users.length} คน`); | |
| console.log(` - Payments: ${payments.length} รายการ`); | |
| console.log(` - Licenses: ${licenses.length} ใบอนุญาต`); | |
| console.log(` - API Keys: ${apiKeys.length} คีย์`); | |
| console.log(` - รายได้รวม: ฿${stats.revenue.total.toLocaleString()}`); | |
| console.log('\n💡 ตอนนี้ระบบมีข้อมูลจริงแล้ว! สามารถรัน server.js ได้ทันที'); | |
| } | |
| // รัน | |
| generateAllData(); | |
Xet Storage Details
- Size:
- 8.66 kB
- Xet hash:
- 325d7d243810a72a0c928bbc6670cca9a58e642970ef3f1995f65e069e0b2075
·
Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.