From b8b75fd65e4add9291b407ca00c0a37d3c3993f9 Mon Sep 17 00:00:00 2001
From: Alberto Defendi <1369-ahl-berto@users.noreply.gitlab.inf.unibz.it>
Date: Thu, 27 May 2021 14:39:50 +0200
Subject: [PATCH] Specify return types and async.

---
 src/api/fetchCookie.ts     | 3 ++-
 src/api/getRole.ts         | 3 ++-
 src/api/getRoles.ts        | 3 ++-
 src/api/isAuthenticated.ts | 3 ++-
 src/api/setRole.ts         | 2 ++
 5 files changed, 10 insertions(+), 4 deletions(-)

diff --git a/src/api/fetchCookie.ts b/src/api/fetchCookie.ts
index d531ad2..de99b41 100644
--- a/src/api/fetchCookie.ts
+++ b/src/api/fetchCookie.ts
@@ -1,9 +1,10 @@
 import axios from 'axios';
 
 /**
+ * @async
  * Call for csrf cookie. This cookie is the user session identifier and
  * must be sent during the login process.
- * @returns csrf cookie
+ * @returns {string} csrf cookie
  */
 export const fetchCookie = async (): Promise<string> =>
   axios('/api/web/csrf').then((res) => res.data.token);
diff --git a/src/api/getRole.ts b/src/api/getRole.ts
index cb06049..395a035 100644
--- a/src/api/getRole.ts
+++ b/src/api/getRole.ts
@@ -1,8 +1,9 @@
 import axios from 'axios';
 
 /**
+ * @async
  * Asks for the current set role.
- * @returns empty if the role is not set or a name between those defined
+ * @returns {string} empty if the role is not set or a name between those defined
  * in {@see userRoles}
  */
 export const getRole = async (): Promise<string> =>
diff --git a/src/api/getRoles.ts b/src/api/getRoles.ts
index 7e00e4e..2d3983e 100644
--- a/src/api/getRoles.ts
+++ b/src/api/getRoles.ts
@@ -1,8 +1,9 @@
 import axios from 'axios';
 
 /**
+ * @async
  * Ask the server all the roles of an user if the user has multiple roles.
- * @returns array of roles.
+ * @returns {string[]} array of roles.
  */
 export const getRoles = async (): Promise<string[]> =>
   axios('/api/web/login/get_roles').then((res) => res.data.roles);
diff --git a/src/api/isAuthenticated.ts b/src/api/isAuthenticated.ts
index 041b4be..ab8dc20 100644
--- a/src/api/isAuthenticated.ts
+++ b/src/api/isAuthenticated.ts
@@ -1,8 +1,9 @@
 import axios from 'axios';
 
 /**
+ * @async
  * Ask the server if the user is authenticated.
- * @returns true or false if the user is authenticated.
+ * @returns {boolean} true or false if the user is authenticated.
  */
 export const isAuthenticated = async (): Promise<boolean> =>
   axios('/api/web/login/is_authenticated').then(
diff --git a/src/api/setRole.ts b/src/api/setRole.ts
index ac08f6f..27087fb 100644
--- a/src/api/setRole.ts
+++ b/src/api/setRole.ts
@@ -1,7 +1,9 @@
 import axios from 'axios';
 
 /**
+ * @async
  * Set the role of the user in the database.
+ * @return {string} role
  */
 export const setRole = async (role: string): Promise<void> =>
   axios.post('/api/web/login/set_role', { role });
-- 
GitLab