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/install-state.gz
.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 datasquirel = {
get: get,
post: post,
media: {
uploadImage: uploadImage,
},
user: {
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: media,
user: user,
};
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",
"version": "1.1.4",
"version": "1.1.5",
"description": "Cloud-based SQL data management tool",
"main": "index.js",
"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
* ==============================================================================
* @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 }) {
/**

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
* ==============================================================================
* @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 }) {
/**