Updates
This commit is contained in:
@@ -121,7 +121,7 @@ function apiCreateUser(_a) {
|
||||
"/images/user-preset-thumbnail.png" }),
|
||||
});
|
||||
if (addUser === null || addUser === void 0 ? void 0 : addUser.insertId) {
|
||||
const newlyAddedUserQuery = `SELECT id,first_name,last_name,email,username,phone,image,image_thumbnail,city,state,country,zip_code,address,verification_status,more_user_data FROM ${dbFullName}.users WHERE id='${addUser.insertId}'`;
|
||||
const newlyAddedUserQuery = `SELECT id,uuid,first_name,last_name,email,username,image,image_thumbnail,verification_status FROM ${dbFullName}.users WHERE id='${addUser.insertId}'`;
|
||||
const newlyAddedUser = yield (0, varDatabaseDbHandler_1.default)({
|
||||
queryString: newlyAddedUserQuery,
|
||||
database: dbFullName,
|
||||
|
||||
@@ -1,13 +0,0 @@
|
||||
import { HttpFunctionResponse, HttpRequestParams } from "../../types";
|
||||
/**
|
||||
* # Generate a http Request
|
||||
*/
|
||||
export default function httpRequest<ReqObj extends {
|
||||
[k: string]: any;
|
||||
} = {
|
||||
[k: string]: any;
|
||||
}, ResObj extends {
|
||||
[k: string]: any;
|
||||
} = {
|
||||
[k: string]: any;
|
||||
}>(params: HttpRequestParams<ReqObj>): Promise<HttpFunctionResponse<ResObj>>;
|
||||
@@ -1,91 +0,0 @@
|
||||
"use strict";
|
||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.default = httpRequest;
|
||||
const node_http_1 = __importDefault(require("node:http"));
|
||||
const node_https_1 = __importDefault(require("node:https"));
|
||||
const querystring_1 = __importDefault(require("querystring"));
|
||||
const serialize_query_1 = __importDefault(require("../../utils/serialize-query"));
|
||||
/**
|
||||
* # Generate a http Request
|
||||
*/
|
||||
function httpRequest(params) {
|
||||
return new Promise((resolve, reject) => {
|
||||
const isUrlEncodedFormBody = params.urlEncodedFormBody;
|
||||
const reqPayloadString = params.body
|
||||
? isUrlEncodedFormBody
|
||||
? querystring_1.default.stringify(params.body)
|
||||
: JSON.stringify(params.body).replace(/\n|\r|\n\r/gm, "")
|
||||
: undefined;
|
||||
const reqQueryString = params.query
|
||||
? (0, serialize_query_1.default)(params.query)
|
||||
: undefined;
|
||||
const paramScheme = params.scheme;
|
||||
const finalScheme = paramScheme == "http" ? node_http_1.default : node_https_1.default;
|
||||
const finalPath = params.path
|
||||
? params.path + (reqQueryString ? reqQueryString : "")
|
||||
: undefined;
|
||||
delete params.body;
|
||||
delete params.scheme;
|
||||
delete params.query;
|
||||
delete params.urlEncodedFormBody;
|
||||
let finalHeaders = {
|
||||
"Content-Type": isUrlEncodedFormBody
|
||||
? "application/x-www-form-urlencoded"
|
||||
: "application/json",
|
||||
};
|
||||
if (reqPayloadString) {
|
||||
finalHeaders["Content-Length"] =
|
||||
Buffer.from(reqPayloadString).length;
|
||||
}
|
||||
finalHeaders = Object.assign(Object.assign({}, finalHeaders), params.headers);
|
||||
/** @type {import("node:https").RequestOptions} */
|
||||
const requestOptions = Object.assign(Object.assign({}, params), { headers: finalHeaders, port: paramScheme == "https" ? 443 : params.port, path: finalPath });
|
||||
const httpsRequest = finalScheme.request(requestOptions,
|
||||
/**
|
||||
* Callback Function
|
||||
*
|
||||
* @description https request callback
|
||||
*/
|
||||
(response) => {
|
||||
var str = "";
|
||||
response.on("data", function (chunk) {
|
||||
str += chunk;
|
||||
});
|
||||
response.on("end", function () {
|
||||
const data = (() => {
|
||||
try {
|
||||
const jsonObj = JSON.parse(str);
|
||||
return jsonObj;
|
||||
}
|
||||
catch (error) {
|
||||
return undefined;
|
||||
}
|
||||
})();
|
||||
resolve({
|
||||
status: response.statusCode || 404,
|
||||
data,
|
||||
str,
|
||||
requestedPath: finalPath,
|
||||
});
|
||||
});
|
||||
response.on("error", (err) => {
|
||||
resolve({
|
||||
status: response.statusCode || 404,
|
||||
str,
|
||||
error: err.message,
|
||||
requestedPath: finalPath,
|
||||
});
|
||||
});
|
||||
});
|
||||
if (reqPayloadString) {
|
||||
httpsRequest.write(reqPayloadString);
|
||||
}
|
||||
httpsRequest.on("error", (error) => {
|
||||
console.log("HTTPS request ERROR =>", error);
|
||||
});
|
||||
httpsRequest.end();
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user