"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.geocodingRouter = void 0;
const express_1 = require("express");
const zod_1 = require("zod");
const geocoding_service_1 = require("./geocoding.service");
const validate_1 = require("../../../middleware/validate");
const auth_middleware_1 = require("../../../middleware/auth.middleware");
const rbac_middleware_1 = require("../../../middleware/rbac.middleware");
const roles_1 = require("../../../utils/roles");
const searchSchema = zod_1.z.object({
    q: zod_1.z.string().min(2, 'Query must be at least 2 characters'),
    limit: zod_1.z.coerce.number().int().min(1).max(10).default(5),
});
const router = (0, express_1.Router)();
exports.geocodingRouter = router;
router.use(auth_middleware_1.authenticate);
router.use((0, rbac_middleware_1.requireRole)(...roles_1.MAP_ROLES));
// GET /api/map/geocoding/search?q=Ottawa&limit=5
router.get('/search', (0, validate_1.validate)(searchSchema, 'query'), async (req, res, next) => {
    try {
        const { q, limit } = req.query;
        const results = await geocoding_service_1.geocodingService.search(q, limit);
        res.json(results);
    }
    catch (err) {
        next(err);
    }
});
//# sourceMappingURL=geocoding.routes.js.map