import express from 'express';
import cors from 'cors';
import contextRouter from './routes/context.js';

const app = express();

app.use(cors({ origin: true }));
const PORT = process.env.PORT || 4002;

app.use(express.json({ limit: '1mb' }));

app.use('/api', contextRouter);

app.get('/health', (_, res) => res.json({ status: 'ok', service: 'geo-device' }));

app.listen(PORT, () => {
  console.log(`Geo Device Service: http://localhost:${PORT}`);
  console.log(`  Context (GET):  /api/context`);
  console.log(`  Context (POST): /api/context (with client data in body)`);
});
