mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-05 10:53:59 +00:00
refactor: share the default tool services between surfaces
Move the composition of the default tool services from the Node MCP server into gods-eye-view/tools/services, a portable export. Given a fetch that resolves the sources' /api paths, it builds the same services in a browser as on the local MCP server, so other surfaces can compose the same catalog. Queries still read only their services.
This commit is contained in:
1 parent
0dbd6375fc
commit
a8b5860e9f
6 files changed
+141
-65
No files matched your search
+7
-63
@@ -1,32 +1,9 @@
|
||||
/**
|
||||
* Local composition of tool services: the portable source factories, pointed
|
||||
* at a running God's Eye View server's `/api` routes.
|
||||
* Local composition of tool services: Core's default services, pointed at a
|
||||
* running God's Eye View server's `/api` routes.
|
||||
*/
|
||||
|
||||
import { GBFS_CITY_REGISTRY } from '../../src/layers/bikeshare/registry.js';
|
||||
import { createBikeshareSource } from '../../src/layers/bikeshare/source.js';
|
||||
import { createCctvSource } from '../../src/layers/cctv/source.js';
|
||||
import { createCycloneSource } from '../../src/layers/cyclones/source.js';
|
||||
import { createUsgsEarthquakeSource } from '../../src/layers/earthquakes/source.js';
|
||||
import { createFirmsSource } from '../../src/layers/firms/source.js';
|
||||
import { createInstallationSource } from '../../src/layers/installations/source.js';
|
||||
import { createLaunchSource } from '../../src/layers/launches/source.js';
|
||||
import { createWfigsPerimeterSource } from '../../src/layers/perimeters/source.js';
|
||||
import { createRadioSource } from '../../src/layers/radio/source.js';
|
||||
import { createSatelliteSource } from '../../src/layers/satellites/source.js';
|
||||
import { createTrafficSource } from '../../src/layers/traffic/source.js';
|
||||
import { createTransitSource } from '../../src/layers/transit/source.js';
|
||||
import { createApplicationRequestServices } from '../../src/services/requests.js';
|
||||
import {
|
||||
createAdsbLolSource,
|
||||
createAisStreamSource,
|
||||
createOpenSkySource,
|
||||
} from '../../src/sources/live/standalone.js';
|
||||
import {
|
||||
createGeocodePlaceService,
|
||||
createPlaceSearchService,
|
||||
createRouteService,
|
||||
} from '../../src/tools/places.js';
|
||||
import { createToolServices } from '../../src/tools/services.js';
|
||||
|
||||
export const DEFAULT_API_BASE = 'http://localhost:4173';
|
||||
|
||||
@@ -49,41 +26,8 @@ export function createApiFetch({
|
||||
|
||||
/** Construct every service Core's tools read, backed by the local server. */
|
||||
export function createLocalToolServices(options = {}) {
|
||||
const fetchImpl = createApiFetch(options);
|
||||
const requests = createApplicationRequestServices({ fetchImpl });
|
||||
return {
|
||||
app: { baseUrl: options.apiBase ?? DEFAULT_API_BASE },
|
||||
earthquakes: createUsgsEarthquakeSource({ fetchImpl }),
|
||||
fires: createFirmsSource({ fetchImpl }),
|
||||
launches: createLaunchSource({ fetchImpl }),
|
||||
aircraft: createOpenSkySource({ fetchImpl }),
|
||||
military: createAdsbLolSource({ fetchImpl }),
|
||||
vessels: createAisStreamSource({
|
||||
fetchImpl,
|
||||
origin: () => new URL(options.apiBase ?? DEFAULT_API_BASE).origin,
|
||||
}),
|
||||
satellites: createSatelliteSource({ fetchImpl }),
|
||||
cctv: createCctvSource({ fetchImpl }),
|
||||
radio: createRadioSource({ fetchImpl }),
|
||||
placeSearch: createPlaceSearchService({ fetchImpl }),
|
||||
routing: createRouteService({ fetchImpl }),
|
||||
bikeshare: {
|
||||
systems: GBFS_CITY_REGISTRY,
|
||||
getStations: createBikeshareSource({ fetchImpl }).getStations,
|
||||
},
|
||||
transit: createTransitSource({ fetchImpl }),
|
||||
traffic: createTrafficSource({ fetchImpl, tileFetchImpl: fetchImpl }),
|
||||
weather: requests.weather,
|
||||
regional: requests.regional,
|
||||
terrain: requests.terrain,
|
||||
summary: requests.summary,
|
||||
features: requests.features,
|
||||
cyclones: createCycloneSource({ fetchImpl }),
|
||||
perimeters: createWfigsPerimeterSource({ fetchImpl }),
|
||||
installations: createInstallationSource({
|
||||
fetchImpl,
|
||||
tileFetchImpl: fetchImpl,
|
||||
}),
|
||||
places: createGeocodePlaceService({ fetchImpl }),
|
||||
};
|
||||
return createToolServices({
|
||||
fetchImpl: createApiFetch(options),
|
||||
appUrl: options.apiBase ?? DEFAULT_API_BASE,
|
||||
});
|
||||
}
|
||||
Reference in new issue
Block a user