diff --git a/apps/back-end/src/routes.ts b/apps/back-end/src/routes.ts index 40eaa87d..cafbb8a2 100644 --- a/apps/back-end/src/routes.ts +++ b/apps/back-end/src/routes.ts @@ -85,11 +85,11 @@ export function MykomapRouter( // Construct and return the implementation object return { - async getDataset({ params: { datasetId }, request, reply }) { + async getDatasetLocations({ params: { datasetId }, request, reply }) { // Validate the parameters some more if (!sendJson(request, reply, filePath("datasets", datasetId))) - throw new TsRestResponseError(contract.getDataset, { + throw new TsRestResponseError(contract.getDatasetLocations, { status: 404, body: { message: `unknown datasetId '${datasetId}'` }, }); @@ -141,7 +141,7 @@ export function MykomapRouter( // Validate the parameters some more if (!sendJson(request, reply, filePath("datasets", datasetId, "config"))) - throw new TsRestResponseError(contract.getDataset, { + throw new TsRestResponseError(contract.getConfig, { status: 404, body: { message: `unknown datasetId '${datasetId}'` }, }); diff --git a/apps/back-end/test/plugin.test.ts b/apps/back-end/test/plugin.test.ts index f43a3bae..851db9b9 100644 --- a/apps/back-end/test/plugin.test.ts +++ b/apps/back-end/test/plugin.test.ts @@ -17,7 +17,7 @@ const opts: MykomapRouterConfig = { // // Operation: dataset -// URL: /dataset/:datasetId +// URL: /dataset/:datasetId/locations // summary: obtains a dataset // req.params // type: object @@ -54,7 +54,7 @@ test("testing dataset", async (t) => { const res = await fastify.inject({ method: "GET", - url: "/dataset/test-A", + url: "/dataset/test-A/locations", payload: undefined, headers: undefined, }); diff --git a/apps/front-end/src/components/map/mapSlice.ts b/apps/front-end/src/components/map/mapSlice.ts index 83ece86f..c76bb3f4 100644 --- a/apps/front-end/src/components/map/mapSlice.ts +++ b/apps/front-end/src/components/map/mapSlice.ts @@ -1,6 +1,6 @@ import { createSelector } from "@reduxjs/toolkit"; import { createAppSlice } from "../../app/createAppSlice"; -import { getDataset } from "../../services"; +import { getDatasetLocations } from "../../services"; export interface MapSliceState { allLocations: number[][]; @@ -26,7 +26,7 @@ export const mapSlice = createAppSlice({ ); } - const response = await getDataset({ params: { datasetId } }); + const response = await getDatasetLocations({ params: { datasetId } }); if (response.status === 200) { const locations = response.body ?? []; diff --git a/apps/front-end/src/services/index.ts b/apps/front-end/src/services/index.ts index b8bff337..9b26ad79 100644 --- a/apps/front-end/src/services/index.ts +++ b/apps/front-end/src/services/index.ts @@ -6,4 +6,9 @@ const client = initClient(contract, { baseHeaders: {}, }); -export const { getDataset, searchDataset, getDatasetItem, getVersion } = client; +export const { + getDatasetLocations, + searchDataset, + getDatasetItem, + getVersion, +} = client; diff --git a/libs/common/src/api/contract.ts b/libs/common/src/api/contract.ts index 3240ebb2..c54615a7 100644 --- a/libs/common/src/api/contract.ts +++ b/libs/common/src/api/contract.ts @@ -78,12 +78,12 @@ export const schemas = { }; export const contract = c.router({ - getDataset: { + getDatasetLocations: { method: "GET", - path: "/dataset/:datasetId", - summary: "obtains a dataset", + path: "/dataset/:datasetId/locations", + summary: "obtains a dataset's locations", description: - "Obtains a dataset by its ID, which by passing in the appropriate options, might be in different formats", + "Obtains all the locations for a dataset by the dataset ID, which by passing in the appropriate options, might be in different formats", pathParams: z.object({ datasetId: DatasetId.openapi({ // description: "uniquely specifies the dataset wanted", diff --git a/libs/common/src/api/mykomap-openapi.json b/libs/common/src/api/mykomap-openapi.json index 7bff9d9b..48eb24d9 100644 --- a/libs/common/src/api/mykomap-openapi.json +++ b/libs/common/src/api/mykomap-openapi.json @@ -1,10 +1,10 @@ { "openapi": "3.0.2", "paths": { - "/dataset/{datasetId}": { + "/dataset/{datasetId}/locations": { "get": { - "description": "Obtains a dataset by its ID, which by passing in the appropriate options, might be in different formats", - "summary": "obtains a dataset", + "description": "Obtains all the locations for a dataset by the dataset ID, which by passing in the appropriate options, might be in different formats", + "summary": "obtains a dataset's locations", "tags": [], "parameters": [ { @@ -17,7 +17,7 @@ } } ], - "operationId": "getDataset", + "operationId": "getDatasetLocations", "responses": { "200": { "description": "200",