Refactor types
This commit is contained in:
+1
-1
@@ -64,7 +64,7 @@ async function addUser({
|
||||
DSQL_PASS?.match(/./) &&
|
||||
DSQL_DB_NAME?.match(/./)
|
||||
) {
|
||||
/** @type {import("../types/database-schema.td").DSQL_DatabaseSchemaType | undefined} */
|
||||
/** @type {import("@/package-shared/types/database-schema.td").DSQL_DatabaseSchemaType | undefined} */
|
||||
let dbSchema;
|
||||
|
||||
try {
|
||||
|
||||
+1
-1
@@ -83,7 +83,7 @@ async function getUser({ key, userId, database, fields }) {
|
||||
DSQL_PASS?.match(/./) &&
|
||||
DSQL_DB_NAME?.match(/./)
|
||||
) {
|
||||
/** @type {import("../types/database-schema.td").DSQL_DatabaseSchemaType | undefined} */
|
||||
/** @type {import("@/package-shared/types/database-schema.td").DSQL_DatabaseSchemaType | undefined} */
|
||||
let dbSchema;
|
||||
|
||||
try {
|
||||
|
||||
+11
-6
@@ -65,7 +65,7 @@ async function loginUser({
|
||||
? temp_code_field
|
||||
? temp_code_field
|
||||
: defaultTempLoginFieldName
|
||||
: null;
|
||||
: undefined;
|
||||
|
||||
/**
|
||||
* Check Encryption Keys
|
||||
@@ -126,7 +126,7 @@ async function loginUser({
|
||||
DSQL_PASS?.match(/./) &&
|
||||
DSQL_DB_NAME?.match(/./)
|
||||
) {
|
||||
/** @type {import("../types/database-schema.td").DSQL_DatabaseSchemaType | undefined} */
|
||||
/** @type {import("@/package-shared/types/database-schema.td").DSQL_DatabaseSchemaType | undefined} */
|
||||
let dbSchema;
|
||||
|
||||
try {
|
||||
@@ -145,6 +145,7 @@ async function loginUser({
|
||||
email_login,
|
||||
email_login_code,
|
||||
email_login_field: emailLoginTempCodeFieldName,
|
||||
token,
|
||||
});
|
||||
}
|
||||
} else {
|
||||
@@ -156,7 +157,8 @@ async function loginUser({
|
||||
* @type {{ success: boolean, payload: import("../types/user.td").DATASQUIREL_LoggedInUser | null, userId?: number, msg?: string }}
|
||||
*/
|
||||
httpResponse = await new Promise((resolve, reject) => {
|
||||
const reqPayload = JSON.stringify({
|
||||
/** @type {PackageUserLoginRequestBody} */
|
||||
const reqPayload = {
|
||||
encryptionKey,
|
||||
payload,
|
||||
database,
|
||||
@@ -164,7 +166,10 @@ async function loginUser({
|
||||
email_login,
|
||||
email_login_code,
|
||||
email_login_field: emailLoginTempCodeFieldName,
|
||||
});
|
||||
token,
|
||||
};
|
||||
|
||||
const reqPayloadJSON = JSON.stringify(reqPayload);
|
||||
|
||||
const httpsRequest = (
|
||||
scheme?.match(/^http$/i) ? http : https
|
||||
@@ -173,7 +178,7 @@ async function loginUser({
|
||||
method: "POST",
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
"Content-Length": Buffer.from(reqPayload).length,
|
||||
"Content-Length": Buffer.from(reqPayloadJSON).length,
|
||||
Authorization: key,
|
||||
},
|
||||
port: localHostPort || 443,
|
||||
@@ -203,7 +208,7 @@ async function loginUser({
|
||||
}
|
||||
);
|
||||
|
||||
httpsRequest.write(reqPayload);
|
||||
httpsRequest.write(reqPayloadJSON);
|
||||
httpsRequest.end();
|
||||
});
|
||||
}
|
||||
|
||||
@@ -103,7 +103,7 @@ async function reauthUser({
|
||||
DSQL_PASS?.match(/./) &&
|
||||
DSQL_DB_NAME?.match(/./)
|
||||
) {
|
||||
/** @type {import("../types/database-schema.td").DSQL_DatabaseSchemaType | undefined} */
|
||||
/** @type {import("@/package-shared/types/database-schema.td").DSQL_DatabaseSchemaType | undefined} */
|
||||
let dbSchema;
|
||||
|
||||
try {
|
||||
|
||||
@@ -114,7 +114,7 @@ async function sendEmailCode({
|
||||
DSQL_PASS?.match(/./) &&
|
||||
DSQL_DB_NAME?.match(/./)
|
||||
) {
|
||||
/** @type {import("../types/database-schema.td").DSQL_DatabaseSchemaType | undefined} */
|
||||
/** @type {import("@/package-shared/types/database-schema.td").DSQL_DatabaseSchemaType | undefined} */
|
||||
let dbSchema;
|
||||
|
||||
try {
|
||||
|
||||
@@ -154,7 +154,7 @@ async function githubAuth({
|
||||
DSQL_PASS?.match(/./) &&
|
||||
DSQL_DB_NAME?.match(/./)
|
||||
) {
|
||||
/** @type {import("../../types/database-schema.td").DSQL_DatabaseSchemaType | undefined} */
|
||||
/** @type {import("@/package-shared/types/database-schema.td").DSQL_DatabaseSchemaType | undefined | undefined} */
|
||||
let dbSchema;
|
||||
|
||||
try {
|
||||
|
||||
@@ -150,7 +150,7 @@ async function googleAuth({
|
||||
DSQL_PASS?.match(/./) &&
|
||||
DSQL_DB_NAME?.match(/./)
|
||||
) {
|
||||
/** @type {import("../../types/database-schema.td").DSQL_DatabaseSchemaType | undefined} */
|
||||
/** @type {import("@/package-shared/types/database-schema.td").DSQL_DatabaseSchemaType | undefined | undefined} */
|
||||
let dbSchema;
|
||||
|
||||
try {
|
||||
|
||||
@@ -57,7 +57,7 @@ async function updateUser({ key, payload, database }) {
|
||||
DSQL_PASS?.match(/./) &&
|
||||
DSQL_DB_NAME?.match(/./)
|
||||
) {
|
||||
/** @type {import("../types/database-schema.td").DSQL_DatabaseSchemaType | undefined} */
|
||||
/** @type {import("@/package-shared/types/database-schema.td").DSQL_DatabaseSchemaType | undefined} */
|
||||
let dbSchema;
|
||||
|
||||
try {
|
||||
|
||||
Reference in New Issue
Block a user