Explorar el Código

Creation route / retourne documentation API

Loquicom hace 5 años
padre
commit
852bd0bb9b
Se han modificado 3 ficheros con 73 adiciones y 1 borrados
  1. 67 0
      node/data/documentation.json
  2. 1 1
      node/package.json
  3. 5 0
      node/src/router.js

+ 67 - 0
node/data/documentation.json

@@ -0,0 +1,67 @@
+{
+  "application": "simple storage server",
+  "ver": "1.0.0",
+  "entrypoint": {
+    "GET": {
+      "/": {
+        "desc": "get information about the server API",
+        "params": null,
+        "return": "description of the API"
+      },
+      "/authentication": {
+        "desc": "",
+        "params": null,
+        "return": [
+          {
+            "key": "success",
+            "value": true
+          },
+          {
+            "key": "authentication",
+            "value": "boolean"
+          }
+        ]
+      }
+    },
+    "POST": {
+      "/register": {
+        "desc": "register a new user",
+        "params": [
+          {
+            "key": "user",
+            "value": "string",
+            "desc": "name of the new user"
+          },
+          {
+            "key": "password",
+            "value": "string",
+            "desc": "password of the new user"
+          }
+        ],
+        "return": [
+          {
+            "key": "success",
+            "value": true
+          }
+        ]
+      }
+    },
+    "Error": {
+      "desc": "Return when error occurs",
+      "returns": [
+        {
+          "key": "success",
+          "value": false
+        },
+        {
+          "key": "code",
+          "value": "int"
+        },
+        {
+          "key": "message",
+          "value": "string"
+        }
+      ]
+    }
+  }
+}

+ 1 - 1
node/package.json

@@ -1,6 +1,6 @@
 {
   "name": "loquicompta_node_server",
-  "version": "0.0.1",
+  "version": "0.2.0",
   "description": "Server de stockage node js",
   "homepage": "https://github.com/Loquicom/",
   "author": {

+ 5 - 0
node/src/router.js

@@ -57,6 +57,7 @@ const router = class Router {
 
     constructor(app) {
         this.app = app;
+        this.doc = require('../data/documentation.json');
     }
 
     /* --- Helper function --- */
@@ -90,6 +91,10 @@ const router = class Router {
     /* --- Definitions des routes --- */
 
     route() {
+        this.app.get('/', [this.verbose, (req, res) => {
+            res.json(this.doc);
+        }]);
+
         this.app.get('/authentication', [this.verbose, (req, res) => {
             res.json(success({authentication: auth.isActivated()}));
         }]);