This commit is contained in:
Tben 2023-05-18 09:22:05 +01:00
parent 84bdfbe6f1
commit e0fdfa9817
6 changed files with 86 additions and 30 deletions

3
.gitignore vendored
View File

@ -128,3 +128,6 @@ dist
.yarn/build-state.yml .yarn/build-state.yml
.yarn/install-state.gz .yarn/install-state.gz
.pnp.* .pnp.*
# typescript
tsconfig.json

View File

@ -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 = { const datasquirel = {
get: get, get: get,
post: post, post: post,
media: { media: media,
uploadImage: uploadImage, user: user,
},
user: {
createUser: createUser,
loginUser: loginUser,
logoutUser: logoutUser,
userAuth: userAuth,
updateUser: updateUser,
},
}; };
module.exports = datasquirel; module.exports = datasquirel;

13
package-lock.json generated Normal file
View File

@ -0,0 +1,13 @@
{
"name": "datasquirel",
"version": "1.1.4",
"lockfileVersion": 2,
"requires": true,
"packages": {
"": {
"name": "datasquirel",
"version": "1.1.4",
"license": "ISC"
}
}
}

View File

@ -1,6 +1,6 @@
{ {
"name": "datasquirel", "name": "datasquirel",
"version": "1.1.4", "version": "1.1.5",
"description": "Cloud-based SQL data management tool", "description": "Cloud-based SQL data management tool",
"main": "index.js", "main": "index.js",
"scripts": { "scripts": {

View File

@ -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 * Main Function
* ============================================================================== * ==============================================================================
* @param {String} key - API Key * @async
* @param {String} db - Database Slug *
* @param {String} query - SQL query * @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 }) { module.exports = async function ({ key, db, query }) {
/** /**

View File

@ -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 * Main Function
* ============================================================================== * ==============================================================================
* @param {String} key - API Key * @async
* @param {String} database - Database Name *
* @param {String | Object} query - SQL query String or Request Object. Eg. { * @param {Object} params - Single object passed
action: "insert | update | delete", * @param {string} params.key - API Key
data: { * @param {string} params.database - Database Name
user_id: user.id, * @param {(Object | string)} params.query - SQL query String or Request Object
user_first_name: user.first_name, * @param {string} [params.query.action="insert"] - Query action => insert | update | delete
user_last_name: user.last_name, * @param {string} params.query.table - Database table slug
}, * @param {string} params.query.identifierColumnName - Name of column(or field) to match
table: "posts", * @param {(string | number)} params.query.identifierValue - Value attached to target column(or field)
identifierColumnName: "id", * @param {Object} params.query.data - data to be inserted: eg. { id: 1267, first_name: John, last_name: Doe }
identifierValue: 1, *
condition: "WHERE likes > 2" * @returns { PostReturn } - Return Object
}
*/ */
module.exports = async function ({ key, query, database }) { module.exports = async function ({ key, query, database }) {
/** /**