updates
This commit is contained in:
parent
b257d71ae3
commit
b2fe996bdd
2
index.js
2
index.js
@ -7,6 +7,7 @@ const get = require("./utils/get");
|
||||
const post = require("./utils/post");
|
||||
const uploadImage = require("./utils/upload-image");
|
||||
const createUser = require("./users/add-user");
|
||||
const updateUser = require("./users/update-user");
|
||||
const loginUser = require("./users/login-user");
|
||||
const logoutUser = require("./users/logout-user");
|
||||
const userAuth = require("./users/user-auth");
|
||||
@ -35,6 +36,7 @@ const datasquirel = {
|
||||
loginUser: loginUser,
|
||||
logoutUser: logoutUser,
|
||||
userAuth: userAuth,
|
||||
updateUser: updateUser,
|
||||
},
|
||||
};
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "datasquirel",
|
||||
"version": "1.1.2",
|
||||
"version": "1.1.3",
|
||||
"description": "Cloud-based SQL data management tool",
|
||||
"main": "index.js",
|
||||
"scripts": {
|
||||
|
@ -19,13 +19,11 @@ const https = require("https");
|
||||
* @param {String} key - API Key
|
||||
* @param {String} database - Target Database
|
||||
* @param {String | 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",
|
||||
first_name: "Benjamin",
|
||||
last_name:"Toby",
|
||||
email:"benoti.san@gmail.com",
|
||||
username:"tben",
|
||||
password:"12345678",
|
||||
}
|
||||
*/
|
||||
module.exports = async function ({ key, payload, database }) {
|
||||
|
88
users/update-user.js
Normal file
88
users/update-user.js
Normal file
@ -0,0 +1,88 @@
|
||||
/**
|
||||
* ==============================================================================
|
||||
* Imports
|
||||
* ==============================================================================
|
||||
*/
|
||||
const https = require("https");
|
||||
|
||||
/** ****************************************************************************** */
|
||||
/** ****************************************************************************** */
|
||||
/** ****************************************************************************** */
|
||||
/** ****************************************************************************** */
|
||||
/** ****************************************************************************** */
|
||||
/** ****************************************************************************** */
|
||||
|
||||
/**
|
||||
* ==============================================================================
|
||||
* Main Function
|
||||
* ==============================================================================
|
||||
* @param {String} key - API Key
|
||||
* @param {String} database - Target Database
|
||||
* @param {String | Object} payload - SQL query String or Request Object. Eg. {
|
||||
first_name: "Benjamin",
|
||||
last_name:"Toby",
|
||||
email:"benoti.san@gmail.com",
|
||||
username:"tben",
|
||||
password:"12345678",
|
||||
}
|
||||
*/
|
||||
module.exports = async function ({ key, payload, database }) {
|
||||
/**
|
||||
* Make https request
|
||||
*
|
||||
* @description make a request to datasquirel.com
|
||||
*/
|
||||
const httpResponse = await new Promise((resolve, reject) => {
|
||||
const reqPayload = JSON.stringify({
|
||||
payload,
|
||||
database,
|
||||
});
|
||||
|
||||
const httpsRequest = https.request(
|
||||
{
|
||||
method: "POST",
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
"Content-Length": reqPayload.length,
|
||||
Authorization: key,
|
||||
},
|
||||
port: 443,
|
||||
hostname: "datasquirel.com",
|
||||
path: `/api/user/update-user`,
|
||||
},
|
||||
|
||||
/**
|
||||
* Callback Function
|
||||
*
|
||||
* @description https request callback
|
||||
*/
|
||||
(response) => {
|
||||
var str = "";
|
||||
|
||||
response.on("data", function (chunk) {
|
||||
str += chunk;
|
||||
});
|
||||
|
||||
response.on("end", function () {
|
||||
resolve(JSON.parse(str));
|
||||
});
|
||||
|
||||
response.on("error", (err) => {
|
||||
reject(err);
|
||||
});
|
||||
}
|
||||
);
|
||||
httpsRequest.write(reqPayload);
|
||||
httpsRequest.end();
|
||||
});
|
||||
|
||||
/** ********************************************** */
|
||||
/** ********************************************** */
|
||||
/** ********************************************** */
|
||||
|
||||
return httpResponse;
|
||||
};
|
||||
|
||||
/** ********************************************** */
|
||||
/** ********************************************** */
|
||||
/** ********************************************** */
|
@ -43,7 +43,7 @@ module.exports = async function ({ key, payload }) {
|
||||
},
|
||||
port: 443,
|
||||
hostname: "datasquirel.com",
|
||||
path: `/api/query/post`,
|
||||
path: `/api/query/add-image`,
|
||||
},
|
||||
|
||||
/**
|
||||
|
Loading…
Reference in New Issue
Block a user