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 post = require("./utils/post");
|
||||||
const uploadImage = require("./utils/upload-image");
|
const uploadImage = require("./utils/upload-image");
|
||||||
const createUser = require("./users/add-user");
|
const createUser = require("./users/add-user");
|
||||||
|
const updateUser = require("./users/update-user");
|
||||||
const loginUser = require("./users/login-user");
|
const loginUser = require("./users/login-user");
|
||||||
const logoutUser = require("./users/logout-user");
|
const logoutUser = require("./users/logout-user");
|
||||||
const userAuth = require("./users/user-auth");
|
const userAuth = require("./users/user-auth");
|
||||||
@ -35,6 +36,7 @@ const datasquirel = {
|
|||||||
loginUser: loginUser,
|
loginUser: loginUser,
|
||||||
logoutUser: logoutUser,
|
logoutUser: logoutUser,
|
||||||
userAuth: userAuth,
|
userAuth: userAuth,
|
||||||
|
updateUser: updateUser,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "datasquirel",
|
"name": "datasquirel",
|
||||||
"version": "1.1.2",
|
"version": "1.1.3",
|
||||||
"description": "Cloud-based SQL data management tool",
|
"description": "Cloud-based SQL data management tool",
|
||||||
"main": "index.js",
|
"main": "index.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
@ -19,13 +19,11 @@ const https = require("https");
|
|||||||
* @param {String} key - API Key
|
* @param {String} key - API Key
|
||||||
* @param {String} database - Target Database
|
* @param {String} database - Target Database
|
||||||
* @param {String | Object} payload - SQL query String or Request Object. Eg. {
|
* @param {String | Object} payload - SQL query String or Request Object. Eg. {
|
||||||
action: "insert | update | delete",
|
first_name: "Benjamin",
|
||||||
data: {
|
last_name:"Toby",
|
||||||
user_id: user.id,
|
email:"benoti.san@gmail.com",
|
||||||
user_first_name: user.first_name,
|
username:"tben",
|
||||||
user_last_name: user.last_name,
|
password:"12345678",
|
||||||
},
|
|
||||||
table: "posts",
|
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
module.exports = async function ({ key, payload, database }) {
|
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,
|
port: 443,
|
||||||
hostname: "datasquirel.com",
|
hostname: "datasquirel.com",
|
||||||
path: `/api/query/post`,
|
path: `/api/query/add-image`,
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
Reference in New Issue
Block a user