feat: implement billing, usage tracking, and administrative geocoding features in API with infrastructure updates

This commit is contained in:
Hamza-Ayed
2026-07-28 04:43:23 +03:00
parent 2f7c2066f7
commit dc9d546733
133 changed files with 3599 additions and 356 deletions
+104 -1
View File
@@ -1,10 +1,43 @@
"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __importStar = (this && this.__importStar) || (function () {
var ownKeys = function(o) {
ownKeys = Object.getOwnPropertyNames || function (o) {
var ar = [];
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
return ar;
};
return ownKeys(o);
};
return function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
__setModuleDefault(result, mod);
return result;
};
})();
var __metadata = (this && this.__metadata) || function (k, v) {
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};
@@ -15,6 +48,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
exports.MapsController = void 0;
const common_1 = require("@nestjs/common");
const swagger_1 = require("@nestjs/swagger");
const fs = __importStar(require("fs"));
const path = __importStar(require("path"));
const maps_service_1 = require("./maps.service");
const api_key_guard_1 = require("../common/guards/api-key.guard");
let MapsController = class MapsController {
@@ -22,6 +57,55 @@ let MapsController = class MapsController {
constructor(mapsService) {
this.mapsService = mapsService;
}
async syncRoutes() {
return this.mapsService.requestRoutingSync();
}
async getStyleJson(theme, res) {
const isDark = theme === 'obsidian';
const filename = isDark ? 'style-dark.json' : 'style.json';
const fallbackFilename = 'style.json';
const pathsToCheck = [
path.join('/data', filename),
path.join(process.cwd(), '../../', filename),
path.join(process.cwd(), filename),
path.join('/data', fallbackFilename),
path.join(process.cwd(), '../../', fallbackFilename),
path.join(process.cwd(), fallbackFilename),
];
let stylePath = '';
for (const p of pathsToCheck) {
if (fs.existsSync(p)) {
stylePath = p;
break;
}
}
if (!stylePath) {
return res.status(404).send('Style not found');
}
try {
const styleRaw = fs.readFileSync(stylePath, 'utf8');
const styleObj = JSON.parse(styleRaw);
if (theme === 'light') {
styleObj.layers.forEach((layer) => {
if (layer.id === 'background') {
layer.paint['background-color'] = '#FFFFFF';
}
});
}
else if (theme === 'obsidian') {
styleObj.layers.forEach((layer) => {
if (layer.id === 'background') {
layer.paint['background-color'] = '#101014';
}
});
}
res.setHeader('Content-Type', 'application/json');
res.send(styleObj);
}
catch (e) {
res.status(500).send('Error parsing style.json');
}
}
async getRoute(query) {
const waypoints = [];
if (query.fromLat && query.fromLng) {
@@ -45,13 +129,32 @@ let MapsController = class MapsController {
waypoints.push([parseFloat(query.toLat), parseFloat(query.toLng)]);
}
const profile = query.profile || 'car';
return this.mapsService.getRoute(waypoints, profile);
const steps = query.steps === 'true';
const locale = query.locale || 'en';
const alternatives = query.alternatives === 'true';
return this.mapsService.getRoute(waypoints, profile, steps, locale, alternatives);
}
async getConfig() {
return this.mapsService.getMapConfig();
}
};
exports.MapsController = MapsController;
__decorate([
(0, common_1.Post)('sync-routes'),
(0, swagger_1.ApiOperation)({ summary: 'Request GraphHopper routing sync 🔄' }),
__metadata("design:type", Function),
__metadata("design:paramtypes", []),
__metadata("design:returntype", Promise)
], MapsController.prototype, "syncRoutes", null);
__decorate([
(0, common_1.Get)('style.json'),
(0, swagger_1.ApiOperation)({ summary: 'Get MapLibre style JSON 🎨' }),
__param(0, (0, common_1.Query)('theme')),
__param(1, (0, common_1.Res)()),
__metadata("design:type", Function),
__metadata("design:paramtypes", [String, Object]),
__metadata("design:returntype", Promise)
], MapsController.prototype, "getStyleJson", null);
__decorate([
(0, common_1.Get)('route'),
(0, swagger_1.ApiOperation)({ summary: 'Calculate a route with dynamic waypoints 🚗' }),