Source: RouterLocation/geoCode.js

// @ts-check
/**
 * @import {ExpressRequestAuthorized, ExpressResponse} from '../types.js'
 */

/**
 * GeoCode Router
 * 
 * API proxy for LocationIQ geocoding service. Protects the API key and applies
 * rate limiting (1 request/second) to stay within LocationIQ free tier limits.
 * 
 * @swagger
 * tags:
 *   - name: GeoCode
 *     description: LocationIQ geocoding proxy
 */

import express from 'express';
import * as geoController from './geoCode/controller.js';

/** @type {express.Express} */
const api = express();

/**
 * @swagger
 * /api/geo/{place}:
 *   get:
 *     summary: Forward geocode a place name
 *     description: Converts a place name or address to coordinates using LocationIQ. Rate-limited to 1 request/second.
 *     tags:
 *       - GeoCode
 *     security:
 *       - bearerAuth: []
 *     parameters:
 *       - in: path
 *         name: place
 *         required: true
 *         schema:
 *           type: string
 *         description: Place name or address to geocode
 *     responses:
 *       200:
 *         description: Geocoding result
 *         content:
 *           application/json:
 *             schema:
 *               type: object
 *               properties:
 *                 success:
 *                   type: boolean
 *                 result:
 *                   type: object
 *                   description: First LocationIQ result object (includes lat, lon, display_name, etc.)
 *                 message:
 *                   type: string
 *                   description: Error message if success is false
 */
// @ts-ignore
api.get('/:place', geoController.geocodePlaceController);

/**
 * @swagger
 * /api/geo/{lat}/{lng}:
 *   get:
 *     summary: Reverse geocode coordinates to a place name
 *     description: Converts latitude/longitude to a human-readable place name using LocationIQ. Rate-limited to 1 request/second.
 *     tags:
 *       - GeoCode
 *     security:
 *       - bearerAuth: []
 *     parameters:
 *       - in: path
 *         name: lat
 *         required: true
 *         schema:
 *           type: number
 *         description: Latitude
 *       - in: path
 *         name: lng
 *         required: true
 *         schema:
 *           type: number
 *         description: Longitude
 *     responses:
 *       200:
 *         description: Reverse geocoding result
 *         content:
 *           application/json:
 *             schema:
 *               type: object
 *               properties:
 *                 success:
 *                   type: boolean
 *                 result:
 *                   type: string
 *                   description: Human-readable place name
 *                 message:
 *                   type: string
 *                   description: Error message if success is false
 */
// @ts-ignore
api.get('/:lat/:lng', geoController.reverseGeocodeController);

export default api;