From e76bf9bf01c00660f17dd87f36d54522a8b30975 Mon Sep 17 00:00:00 2001 From: Loki Sinclair Date: Tue, 12 Dec 2023 17:04:39 +0000 Subject: [PATCH] fixes --- files/list.json | 2 +- src/api/v1/controllers/dataset.controller.ts | 2 +- src/api/v1/services/dataset.service.ts | 28 +------------------- 3 files changed, 3 insertions(+), 29 deletions(-) diff --git a/files/list.json b/files/list.json index 9b5ead3..a7a554d 100644 --- a/files/list.json +++ b/files/list.json @@ -6,7 +6,7 @@ "description": "Sample description here", "type": "dataset", "persistentId": "e96e36ba-30ca-4c25-bc55-fab02d72a51c", - "self": "https://fair.preview.aridhia.io/api/datasets/e96e36ba-30ca-4c25-bc55-fab02d72a51c", + "self": "http://example-url.com/api/datasets/e96e36ba-30ca-4c25-bc55-fab02d72a51c", "version": "0.0.0", "issued": "2023-02-13T14:10:31.640Z", "modified": "2023-09-04T10:53:01.239Z", diff --git a/src/api/v1/controllers/dataset.controller.ts b/src/api/v1/controllers/dataset.controller.ts index 3d6130c..b072d39 100644 --- a/src/api/v1/controllers/dataset.controller.ts +++ b/src/api/v1/controllers/dataset.controller.ts @@ -26,7 +26,7 @@ export default class DatasetController extends BaseController { return res .status(200) - .json({ query: { q: q || '', total: datasetTotal, limit: limitInt, offset: offsetInt }, items: datasets }); + .json(datasets); } catch (err) { this._logger.sendDataInLogging({ data: err.name }, 'ERROR'); this._logger.sendDataInLogging({ data: (err).message }, 'ERROR'); diff --git a/src/api/v1/services/dataset.service.ts b/src/api/v1/services/dataset.service.ts index fefc0f4..e30f883 100644 --- a/src/api/v1/services/dataset.service.ts +++ b/src/api/v1/services/dataset.service.ts @@ -7,33 +7,7 @@ export default class DatasetService { const file = fs.readFileSync("./files/list.json", 'utf-8'); const parsedJSON = JSON.parse(file); - const datasetData = { - persistentId : parsedJSON.identifier, - "@schema" : parsedJSON["@schema"], - version : parsedJSON.version, - issued : parsedJSON.issued, - modified : parsedJSON.modified, - name : parsedJSON.summary.title, - description : parsedJSON.summary.abstract, - type : "dataset", - source : parsedJSON.summary.publisher.name, - self : "http://example-url.com/api/datasets/" + parsedJSON.identifier - } - - datasets.push(datasetData); - - // Check the offset is valid - if (offset < datasets.length) - { - datasets = datasets.slice(offset); - } - - if (!isNaN(limit) && limit > 0) - { - datasets = datasets.slice(0, limit); - } - - return datasets; + return parsedJSON; } public async getDataset(pid: string) {