Skip to content

Commit

Permalink
Merge branch '26-rename-getdataset'
Browse files Browse the repository at this point in the history
See PR #34
  • Loading branch information
Nick Stokoe committed Oct 28, 2024
2 parents aac1b7f + fd8d89d commit 0c818ec
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 16 deletions.
6 changes: 3 additions & 3 deletions apps/back-end/src/routes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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}'` },
});
Expand Down Expand Up @@ -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}'` },
});
Expand Down
4 changes: 2 additions & 2 deletions apps/back-end/test/plugin.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ const opts: MykomapRouterConfig = {

//
// Operation: dataset
// URL: /dataset/:datasetId
// URL: /dataset/:datasetId/locations
// summary: obtains a dataset
// req.params
// type: object
Expand Down Expand Up @@ -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,
});
Expand Down
4 changes: 2 additions & 2 deletions apps/front-end/src/components/map/mapSlice.ts
Original file line number Diff line number Diff line change
@@ -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[][];
Expand All @@ -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 ?? [];
Expand Down
7 changes: 6 additions & 1 deletion apps/front-end/src/services/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,9 @@ const client = initClient(contract, {
baseHeaders: {},
});

export const { getDataset, searchDataset, getDatasetItem, getVersion } = client;
export const {
getDatasetLocations,
searchDataset,
getDatasetItem,
getVersion,
} = client;
8 changes: 4 additions & 4 deletions libs/common/src/api/contract.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
8 changes: 4 additions & 4 deletions libs/common/src/api/mykomap-openapi.json
Original file line number Diff line number Diff line change
@@ -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": [
{
Expand All @@ -17,7 +17,7 @@
}
}
],
"operationId": "getDataset",
"operationId": "getDatasetLocations",
"responses": {
"200": {
"description": "200",
Expand Down

0 comments on commit 0c818ec

Please sign in to comment.