diff --git a/cloud-wrapper/src/index.ts b/cloud-wrapper/src/index.ts index c4b4144a..d072e821 100644 --- a/cloud-wrapper/src/index.ts +++ b/cloud-wrapper/src/index.ts @@ -6,9 +6,9 @@ import dotenv from 'dotenv'; import http from 'http'; import { WebSocketServer } from 'ws'; import { BrainyData } from '@soulcraft/brainy'; -import { setupRoutes } from './routes'; -import { initializeBrainy } from './services/brainyService'; -import { setupWebSocketHandlers } from './websocket'; +import { setupRoutes } from './routes.js'; +import { initializeBrainy } from './services/brainyService.js'; +import { setupWebSocketHandlers } from './websocket.js'; // Load environment variables dotenv.config(); @@ -32,11 +32,12 @@ app.get('/health', (req, res) => { }); // Setup API routes +const apiRouter = setupRoutes(); app.use('/api', (req, res, next) => { // Attach brainy instance to request (req as any).brainy = brainyInstance; next(); -}, setupRoutes()); +}, apiRouter); // Start the server async function startServer() { diff --git a/src/unified.ts b/src/unified.ts index e5cfde85..8c737095 100644 --- a/src/unified.ts +++ b/src/unified.ts @@ -1,20 +1,15 @@ /** * Unified entry point for Brainy - * This file exports everything from index.ts and adds environment detection - * to ensure the library works in any environment (Node.js, browser, serverless) + * This file exports everything from index.ts + * Environment detection is handled by the build process */ -// Environment detection (will be replaced by the build process) -const isBrowser = typeof window !== 'undefined' -const isNode = - typeof process !== 'undefined' && process.versions && process.versions.node -const isServerless = !isBrowser && !isNode - // Export environment information +// These values will be populated by the build process intro code export const environment = { - isBrowser, - isNode, - isServerless + isBrowser: typeof window !== 'undefined', + isNode: typeof process !== 'undefined' && process.versions && process.versions.node, + isServerless: typeof window === 'undefined' && (typeof process === 'undefined' || !process.versions || !process.versions.node) } // Re-export everything from index.ts