import express from 'express';
import cors from 'cors';
import localeRouter from './routes/locale.js';
import translationsRouter from './routes/translations.js';

const app = express();

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

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

app.use('/api', localeRouter);
app.use('/api', translationsRouter);

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

app.listen(PORT, () => {
  console.log(`Localization Service: http://localhost:${PORT}`);
  console.log(`  Locale (GET):       /api/locale`);
  console.log(`  Locale (POST):      /api/locale (with client data in body)`);
  console.log(`  Translations:      /api/translations/:locale`);
  console.log(`  Supported locales:  /api/locales`);
});
