39 lines
1.2 KiB
JavaScript
39 lines
1.2 KiB
JavaScript
require ('dotenv').config();
|
|
const express = require('express');
|
|
const {getEnv} = require('@nexusai/shared');
|
|
const chatRouter = require('./routes/chat');
|
|
const sessionsRouter = require('./routes/sessions');
|
|
const cors = require('cors');
|
|
|
|
const app = express();
|
|
app.use(express.json());
|
|
|
|
const PORT = getEnv('PORT', '4000'); // Default to 4000 if PORT is not set
|
|
|
|
app.use(cors({
|
|
origin: [
|
|
getEnv('CORS_ORIGIN', 'http://localhost:5173'),
|
|
'http://localhost:5173',
|
|
],
|
|
methods: ['GET', 'POST', 'DELETE'],
|
|
allowedHeaders: ['Content-Type'],
|
|
}))
|
|
|
|
// Health check endpoint
|
|
app.get('/health', (req, res) => {
|
|
res.json({
|
|
service: 'Orchestration Service',
|
|
status: 'healthy',
|
|
memoryService: getEnv('MEMORY_SERVICE_URL', 'http://localhost:3002'),
|
|
embeddingService: getEnv('EMBEDDING_SERVICE_URL', 'http://localhost:3003'),
|
|
inferenceService: getEnv('INFERENCE_SERVICE_URL', 'http://localhost:3001'),
|
|
});
|
|
});
|
|
|
|
app.use('/chat', chatRouter);
|
|
app.use('/sessions', sessionsRouter);
|
|
|
|
/******* Start the server ************/
|
|
app.listen(PORT, () => {
|
|
console.log(`Orchestration Service is running on port ${PORT}`);
|
|
}); |