import express from 'express'; import { CIQClient } from '@ninebit/ciq'; import bodyParser from 'body-parser'; const app = express(); const port = 7860; const apiKey = '99edded2-a45d-456e-bf49-af2c9b1ccd2f'; // or use process.env.API_KEY const client = new CIQClient(apiKey); app.use(bodyParser.json()); app.get('/', (req, res) => { res.send('🚀 CIQ Chatbot backend is running!'); }); app.post('/query', async (req, res) => { const { filePath, query } = req.body; try { if (filePath) await client.ingestFile(filePath); const result = await client.ragQuery(query); res.json({ result }); } catch (error) { res.status(500).json({ error: error.message }); } }); app.listen(port, () => { console.log(`Server running on http://localhost:${port}`); });