Skip to content

Cloud Functions API

  • functions/src/index.ts — firebase-functions v2
  • Exports: api (Express HTTP), setUserRole, setUserAiAccess, deleteAccount (callable)
  • REST API at /api/v1/* — full CRUD for all entities
  • Auth: Firebase Bearer token or per-user API key (x-api-key: mg_*)
  • Node 20

Logging

All route handlers use structured logging:

typescript
console.log("[tag] action", { mallId, floorId, ...context });

Tags: [floors], [features], [occupancies], [source-images], [App Check]

Key Endpoints

Malls

GET/POST /malls, GET/PATCH/DELETE /malls/:mallId, POST /malls/:mallId/logo, POST /malls/:mallId/cover

Floors

GET/POST /malls/:mallId/floors, GET/PATCH/DELETE /malls/:mallId/floors/:floorId

Floor Plans & Features

POST /malls/:mallId/floors/:floorId/floorplan (upload), GET /malls/:mallId/floors/:floorId/vector-map (full vector data), GET/POST .../features, PATCH/DELETE .../features/:featureId

Occupancies

GET/POST .../unit-occupancies, POST .../unit-occupancies/batch, PATCH/DELETE .../unit-occupancies/:occupancyId

Stores

GET/POST .../stores, POST .../stores/batch, PATCH .../stores/batch, GET /malls/:mallId/stores (cross-floor)

Brands

GET/POST /brands, GET/PATCH/DELETE /brands/:brandId, POST /brands/:brandId/logo

Streets

GET/POST /streets, GET/PATCH/DELETE /streets/:id, GET/POST .../businesses, GET/POST .../buildings

GET /malls/:mallId/gallery, GET /streets/:id/gallery, GET /cities/:countryCode/:city/gallery

AI

POST /malls/:mallId/floors/:floorId/ai-populate, POST /streets/:streetGuideId/ai-populate