diff --git a/.gitignore b/.gitignore index c6bba59..3f1516e 100644 --- a/.gitignore +++ b/.gitignore @@ -128,3 +128,6 @@ dist .yarn/build-state.yml .yarn/install-state.gz .pnp.* + +# typescript +tsconfig.json diff --git a/index.js b/index.js index 7c02760..da50a7f 100644 --- a/index.js +++ b/index.js @@ -21,23 +21,47 @@ const userAuth = require("./users/user-auth"); /** * ============================================================================== - * Main Function + * User Functions Object * ============================================================================== - * @param {Object} mailObject - foundUser if any + * @type {Object} + * @property {Function} createUser - Create User Function + * @property {Function} loginUser - Login User Function + * @property {Function} logoutUser - Logout User Function + * @property {Function} userAuth - User Auth Function + * @property {Function} updateUser - Update User Function + */ +const user = { + createUser: createUser, + loginUser: loginUser, + logoutUser: logoutUser, + userAuth: userAuth, + updateUser: updateUser, +}; + +/** + * ============================================================================== + * Media Functions Object + * ============================================================================== + * @type {Object} + * @property {Function} uploadImage - Upload Image async Function + */ +const media = { + uploadImage: uploadImage, +}; + +/** + * ============================================================================== + * Main Export + * ============================================================================== + * @type {Object} + * @property {Function} get - get Function + * @property {Function} post - post Function */ const datasquirel = { get: get, post: post, - media: { - uploadImage: uploadImage, - }, - user: { - createUser: createUser, - loginUser: loginUser, - logoutUser: logoutUser, - userAuth: userAuth, - updateUser: updateUser, - }, + media: media, + user: user, }; module.exports = datasquirel; diff --git a/package-lock.json b/package-lock.json new file mode 100644 index 0000000..adf39bb --- /dev/null +++ b/package-lock.json @@ -0,0 +1,13 @@ +{ + "name": "datasquirel", + "version": "1.1.4", + "lockfileVersion": 2, + "requires": true, + "packages": { + "": { + "name": "datasquirel", + "version": "1.1.4", + "license": "ISC" + } + } +} diff --git a/package.json b/package.json index 0f8ea32..21866b4 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "datasquirel", - "version": "1.1.4", + "version": "1.1.5", "description": "Cloud-based SQL data management tool", "main": "index.js", "scripts": { diff --git a/utils/get.js b/utils/get.js index 4edfdfa..f90d129 100644 --- a/utils/get.js +++ b/utils/get.js @@ -12,13 +12,24 @@ const https = require("https"); /** ****************************************************************************** */ /** ****************************************************************************** */ +/** + * @typedef {Object} GetReturn + * @property {boolean} success - Did the function run successfully? + * @property {(Object[]|string)} [payload=[]] - The Y Coordinate + */ + /** * ============================================================================== * Main Function * ============================================================================== - * @param {String} key - API Key - * @param {String} db - Database Slug - * @param {String} query - SQL query + * @async + * + * @param {Object} params - Single object passed + * @param {string} params.key - API Key + * @param {string} params.db - Database Name + * @param {(string | Object)} params.query - SQL Query + * + * @returns {GetReturn} - Return Object */ module.exports = async function ({ key, db, query }) { /** diff --git a/utils/post.js b/utils/post.js index 84dd2d4..66e9817 100644 --- a/utils/post.js +++ b/utils/post.js @@ -12,24 +12,29 @@ const https = require("https"); /** ****************************************************************************** */ /** ****************************************************************************** */ +/** + * @typedef {Object} PostReturn + * @property {boolean} success - Did the function run successfully? + * @property {(Object[]|string)} [payload=[]] - The Y Coordinate + */ + /** * ============================================================================== * Main Function * ============================================================================== - * @param {String} key - API Key - * @param {String} database - Database Name - * @param {String | Object} query - 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", - identifierColumnName: "id", - identifierValue: 1, - condition: "WHERE likes > 2" - } + * @async + * + * @param {Object} params - Single object passed + * @param {string} params.key - API Key + * @param {string} params.database - Database Name + * @param {(Object | string)} params.query - SQL query String or Request Object + * @param {string} [params.query.action="insert"] - Query action => insert | update | delete + * @param {string} params.query.table - Database table slug + * @param {string} params.query.identifierColumnName - Name of column(or field) to match + * @param {(string | number)} params.query.identifierValue - Value attached to target column(or field) + * @param {Object} params.query.data - data to be inserted: eg. { id: 1267, first_name: John, last_name: Doe } + * + * @returns { PostReturn } - Return Object */ module.exports = async function ({ key, query, database }) { /**