perplexity-hackathon-LawMitra / perplexity_hackathon / demo / scripts / server.js
server.js
Raw
import express from 'express';
import cors from 'cors';
import chalk from 'chalk';

const app = express();

// Middleware
app.use(cors());
app.use(express.json());

// Mock data storage
const mockData = {
  users: [],
  cases: [],
  messages: []
};

// Mock routes
app.get('/api/status', (req, res) => {
  res.json({ status: 'Demo server is running' });
});

app.post('/api/chat', (req, res) => {
  const { message } = req.body;
  console.log(chalk.blue('Received message:'), message);
  
  // Simulate processing delay
  setTimeout(() => {
    res.json({
      response: `Demo response to: ${message}`,
      timestamp: new Date()
    });
  }, 1000);
});

// Start server
const port = 3001;
app.listen(port, () => {
  console.log(chalk.green(`Demo server running on port ${port}`));
  console.log(chalk.yellow('This is a mock server for demonstration purposes'));
});