diff --git a/index.js b/index.js index 9fcee69..a366ecb 100644 --- a/index.js +++ b/index.js @@ -23,13 +23,6 @@ const userAuth = require("./users/user-auth"); * ============================================================================== * User Functions Object * ============================================================================== - * @type {{ - * createUser: Function - * loginUser: Function - * logoutUser: Function - * userAuth: Function - * updateUser: Function - * }} */ const user = { createUser: createUser, @@ -43,9 +36,6 @@ const user = { * ============================================================================== * Media Functions Object * ============================================================================== - * @type {{ - * uploadImage: Function - * }} */ const media = { uploadImage: uploadImage, @@ -55,21 +45,6 @@ const media = { * ============================================================================== * Main Export * ============================================================================== - * @type {{ - * get: Function, - * post: Function, - * media: { - * uploadImage: Function - * }, - * user: { - * createUser: Function - * loginUser: Function - * logoutUser: Function - * userAuth: Function - * updateUser: Function - * }, - * }} - * ============================================================================== */ const datasquirel = { get: get, diff --git a/package.json b/package.json index e72258b..7b005ec 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "datasquirel", - "version": "1.1.6", + "version": "1.1.7", "description": "Cloud-based SQL data management tool", "main": "index.js", "scripts": { diff --git a/users/add-user.js b/users/add-user.js index c0e8d3a..7cbcca5 100644 --- a/users/add-user.js +++ b/users/add-user.js @@ -12,19 +12,25 @@ const https = require("https"); /** ****************************************************************************** */ /** ****************************************************************************** */ +/** + * @typedef {Promise} FunctionReturn + * @property {boolean} success - Did the function run successfully? + * @property {(Object[]|string)} [payload=[]] - Payload + */ + /** * ============================================================================== * Main Function * ============================================================================== - * @param {String} key - API Key - * @param {String} database - Target Database - * @param {String | Object} payload - User Object. Eg. { - first_name: "Benjamin", - last_name:"Toby", - email:"benoti.san@gmail.com", - username:"tben", - password:"12345678", - } + * @async + * + * @param {{ + * key: string, + * payload: string, + * database: string + * }} + * + * @returns {FunctionReturn} */ module.exports = async function ({ key, payload, database }) { /** diff --git a/users/login-user.js b/users/login-user.js index 5e0e973..4a317cb 100644 --- a/users/login-user.js +++ b/users/login-user.js @@ -13,24 +13,25 @@ const encrypt = require("../functions/encrypt"); /** ****************************************************************************** */ /** ****************************************************************************** */ +/** + * @typedef {Promise} FunctionReturn + * @property {boolean} success - Did the function run successfully? + * @property {(Object[]|string)} [payload=[]] - Payload + */ + /** * ============================================================================== * Main Function * ============================================================================== - * @param {String} key - API Key - * @param {String} database - Target Database - * @param {Object} payload - SQL query String or Request Object. Eg. { - action: "insert | update | delete", - data: { - user_id: user.id, - user_first_name: user.first_name, - user_last_name: user.last_name, - }, - table: "posts", - } - * @param {Object} response - Http response object - * @param {String} encryptionKey - Encryption Key - * @param {String} encryptionSalt - Encryption Salt + * @param {object} params - Single Param object containing params + * @param {String} params.key - API Key + * @param {String} params.database - Target Database + * @param {(Object | string)} [params.payload={ action: "insert | update | delete", data: {}, table: "posts" }] SQL query String or Request + * @param {Object} params.response - Http response object + * @param {String} params.encryptionKey - Encryption Key + * @param {String} params.encryptionSalt - Encryption Salt + * + * @returns {FunctionReturn} */ module.exports = async function ({ key, payload, database, response, encryptionKey, encryptionSalt }) { /** diff --git a/users/logout-user.js b/users/logout-user.js index a00133b..9b007bd 100644 --- a/users/logout-user.js +++ b/users/logout-user.js @@ -2,7 +2,9 @@ * ============================================================================== * Main Function * ============================================================================== - * @param {Object} response - Http response object + * @param {object} params - Single Param object containing params + * @param {object} params.request - Http request object + * @param {object} params.response - Http response object */ module.exports = function ({ request, response }) { /** diff --git a/users/update-user.js b/users/update-user.js index e089199..74e3f3a 100644 --- a/users/update-user.js +++ b/users/update-user.js @@ -12,20 +12,25 @@ const https = require("https"); /** ****************************************************************************** */ /** ****************************************************************************** */ +/** + * @typedef {Promise} FunctionReturn + * @property {boolean} success - Did the function run successfully? + * @property {(Object[]|string)} [payload=[]] - Payload + */ + /** * ============================================================================== * Main Function * ============================================================================== - * @param {String} key - API Key - * @param {String} database - Target Database - * @param {String | Object} payload - User Object. Eg. { - id: 3, ****Required - first_name: "Benjamin", - last_name:"Toby", - email:"benoti.san@gmail.com", - username:"tben", - password:"12345678", - } + * @async + * + * @param {object} params - API Key + * @param {String} params.key - API Key + * @param {String} params.database - Target Database + * @param {String | Object} [params.payload={ id: 4, first_name: "Benjamin" }] - User Object. + * @param {number} [params.payload.id] - User id => Required + * + * @returns {FunctionReturn} */ module.exports = async function ({ key, payload, database }) { /**