Files
jason5ng32andClaude Opus 5.5 c29e48687b Refactor(layout): split backend-only code out of common/, group frontend utils
common/ had become the backend's library: 30 of its 41 modules were
imported by nothing in the frontend, so the name no longer said what
belonged there. It now holds only what the frontend or the build imports
too; backend-only code moved to server/, flat except for datasets/ (the
dataset engine and its readers). The *-db/ dataset directories stay in
common/: self-hosting docs and Docker volumes mount those paths.

frontend/utils/ keeps its app-wide modules at the root and gains ip/
(IP / ASN shaping and validation), report/ (the report pipeline) and
features/ (the pure layer of a single feature). Paths only — no logic
changes. The Dockerfile copies server/, and the AGENTS.md files say where
a new module goes.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-05 13:10:02 +08:00

20 lines
672 B
JavaScript

import { lookupMaxMind } from '../server/datasets/maxmind-service.js';
import logger from '../server/logger.js';
export default (req, res) => {
// Presence, validity and public routability guaranteed by the
// requirePublicIP middleware — a reserved address never reaches here.
const ip = req.query.ip;
// The raw tag goes straight in: the service owns the language set and
// normalizes onto it.
const lang = req.query.lang;
try {
res.json(lookupMaxMind(ip, lang));
} catch (e) {
logger.error({ err: e, ip, lang }, 'maxmind handler failed');
res.status(e.statusCode || 500).json({ error: e.message });
}
}