From 386a7e3de67d09f63f6a3de7267b09e90a32eaa6 Mon Sep 17 00:00:00 2001
From: Benoit Lavenier <benoit.lavenier@e-is.pro>
Date: Wed, 17 May 2023 10:28:35 +0200
Subject: [PATCH] [enh] Add config's storage into /node/summary - close #1441

---
 app/modules/bma/lib/controllers/node.ts  |  7 ++++++-
 app/modules/bma/lib/dtos.ts              |  8 ++++++++
 doc/HTTP_API.md                          | 10 +++++++---
 test/fast/modules/bma/bma-module-test.ts |  2 ++
 4 files changed, 23 insertions(+), 4 deletions(-)

diff --git a/app/modules/bma/lib/controllers/node.ts b/app/modules/bma/lib/controllers/node.ts
index a71870e7b..84073fda0 100644
--- a/app/modules/bma/lib/controllers/node.ts
+++ b/app/modules/bma/lib/controllers/node.ts
@@ -14,7 +14,6 @@
 "use strict";
 import { AbstractController } from "./AbstractController";
 import { HttpSandbox, HttpSandboxes, HttpSummary } from "../dtos";
-import { constants } from "buffer";
 
 export class NodeBinding extends AbstractController {
   summary = (): HttpSummary => {
@@ -23,6 +22,12 @@ export class NodeBinding extends AbstractController {
         software: "duniter",
         version: this.server.version,
         forkWindowSize: this.server.conf.forksize,
+        storage: {
+          transactions: this.server.conf.storage
+            ? this.server.conf.storage.transactions
+            : true, // true by default (see app/module/config.ts)
+          wotwizard: this.server.conf.storage?.wotwizard || false, // false by default (see app/module/config.ts)
+        },
       },
     };
   };
diff --git a/app/modules/bma/lib/dtos.ts b/app/modules/bma/lib/dtos.ts
index e236aa611..5f608f737 100644
--- a/app/modules/bma/lib/dtos.ts
+++ b/app/modules/bma/lib/dtos.ts
@@ -21,6 +21,10 @@ export const Summary = {
     software: String,
     version: String,
     forkWindowSize: Number,
+    storage: {
+      transactions: Boolean,
+      wotwizard: Boolean,
+    },
   },
 };
 
@@ -29,6 +33,10 @@ export interface HttpSummary {
     software: string;
     version: string;
     forkWindowSize: number;
+    storage: {
+      transactions: boolean;
+      wotwizard: boolean;
+    };
   };
 }
 
diff --git a/doc/HTTP_API.md b/doc/HTTP_API.md
index a6411a092..f5bb6f942 100644
--- a/doc/HTTP_API.md
+++ b/doc/HTTP_API.md
@@ -239,13 +239,17 @@ GET technical informations about this peer.
 
 **Returns**
 
-Technical informations about the node.
+Technical information about the node.
 ```json
 {
   "duniter": {
     "software": "duniter",
-    "version": "0.10.3",
-    "forkWindowSize": 10
+    "version": "1.8.7",
+    "forkWindowSize": 100,
+    "storage": {
+      "transaction": true,
+      "wotwizard": false
+    }
   }
 }
 ```
diff --git a/test/fast/modules/bma/bma-module-test.ts b/test/fast/modules/bma/bma-module-test.ts
index 58c20ea81..cbec2c94a 100644
--- a/test/fast/modules/bma/bma-module-test.ts
+++ b/test/fast/modules/bma/bma-module-test.ts
@@ -51,6 +51,8 @@ describe('Module usage', () => {
     });
     should.exist(json);
     json.should.have.property('duniter').property('software').equal('duniter');
+    json.should.have.property('duniter').property('storage').property('transactions').equal(true);
+    json.should.have.property('duniter').property('storage').property('wotwizard').equal(false);
   })
 
   it('remoteipv4 should NOT be filled if remote Host is declared', async () => {
-- 
GitLab