ice/src/routes/config.ts
Claude Code 536660e818 Fix inconsistent Mapbox capitalization
Standardized "MapBox" to "Mapbox" throughout the codebase
to match official branding. Updated:

- Documentation (CLAUDE.md, README.md)
- Source code comments and console logs
- API documentation and Swagger definitions

This ensures consistent branding and professional presentation.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-07-06 00:36:36 -04:00

55 lines
No EOL
2 KiB
TypeScript

import express, { Request, Response, Router } from 'express';
export default (): Router => {
const router = express.Router();
/**
* @swagger
* /api/config:
* get:
* tags:
* - Public API
* summary: Get API configuration
* description: Returns public API configuration including Mapbox access token for geocoding
* responses:
* 200:
* description: API configuration retrieved successfully
* content:
* application/json:
* schema:
* $ref: '#/components/schemas/ApiConfig'
* examples:
* with_mapbox:
* summary: Configuration with Mapbox token
* value:
* mapboxAccessToken: "pk.eyJ1IjoiZXhhbXBsZSIsImEiOiJhYmNkZWZnIn0.example"
* hasMapbox: true
* without_mapbox:
* summary: Configuration without Mapbox token
* value:
* mapboxAccessToken: null
* hasMapbox: false
* 500:
* description: Internal server error
* content:
* application/json:
* schema:
* $ref: '#/components/schemas/Error'
*/
router.get('/', (req: Request, res: Response): void => {
console.log('📡 API Config requested');
const MAPBOX_ACCESS_TOKEN: string | undefined = process.env.MAPBOX_ACCESS_TOKEN || undefined;
console.log('Mapbox token present:', !!MAPBOX_ACCESS_TOKEN);
console.log('Mapbox token starts with pk:', MAPBOX_ACCESS_TOKEN?.startsWith('pk.'));
res.json({
// Mapbox tokens are designed to be public (they have domain restrictions)
mapboxAccessToken: MAPBOX_ACCESS_TOKEN || null,
hasMapbox: !!MAPBOX_ACCESS_TOKEN
// SECURITY: Google Maps API key is kept server-side only
});
});
return router;
};