UNPKG

@codai/memorai

Version:

Universal Database & Storage Service for CODAI Ecosystem - CBD Backend

63 lines (48 loc) โ€ข 1.66 kB
/** * Test REST API Server functionality */ import { MemoraiService } from '../src/services/MemoraiService' import { MemoraiAPIServer } from '../src/api/server' async function testAPIServer() { console.log('๐Ÿงช Testing MEMORAI API Server...') try { // Create minimal config const config = { database: { url: 'file:./test.db', type: 'sqlite' as const } } // Initialize services console.log('๐Ÿ“ฆ Initializing services...') const memoraiService = await MemoraiService.create(config) // Create API server console.log('๐ŸŒ Creating API server...') const apiServer = new MemoraiAPIServer(memoraiService, memoraiService.configuration) // Start server console.log('๐Ÿš€ Starting API server...') await apiServer.start(3002, 'localhost') console.log('โœ… API Server started successfully!') // Test health endpoint console.log('๐Ÿฅ Testing health endpoint...') const response = await fetch('http://localhost:3002/health') const health = await response.json() console.log('Health check result:', health) if (health.status === 'healthy') { console.log('โœ… Health check passed!') } else { console.log('โŒ Health check failed!') } // Stop server console.log('๐Ÿ›‘ Stopping server...') await apiServer.stop() console.log('๐ŸŽ‰ Test completed successfully!') } catch (error) { console.error('โŒ Test failed:', error) process.exit(1) } } // Run test if this file is executed directly if (require.main === module) { testAPIServer() }