Type Checking

This commit is contained in:
Tben 2023-08-07 05:10:45 +01:00
parent 65d6424dcf
commit 4da665efd4
4 changed files with 12 additions and 8 deletions

View File

@ -1,6 +1,6 @@
{
"name": "datasquirel",
"version": "1.2.5",
"version": "1.2.6",
"description": "Cloud-based SQL data management tool",
"main": "index.js",
"scripts": {

View File

@ -54,7 +54,7 @@ function logoutUser({ request, response, database }) {
/** ********************************************** */
/** ********************************************** */
} catch (error) {
console.log(error.message);
console.log(error);
return {
success: false,

View File

@ -5,6 +5,7 @@
* Imports
* ==============================================================================
*/
const http = require("http");
const decrypt = require("../functions/decrypt");
const parseCookies = require("../utils/functions/parseCookies");
@ -19,7 +20,7 @@ const parseCookies = require("../utils/functions/parseCookies");
* @typedef {object} AuthenticatedUserObject
* @property {boolean} success - Did the function run successfully?
* @property {import("../types/user.td").DATASQUIREL_LoggedInUser | null} payload - Payload
* @property {string} [msg] - Response Message
* @property {string | unknown} [msg] - Response Message
*/
/**
@ -29,7 +30,7 @@ const parseCookies = require("../utils/functions/parseCookies");
* with the user's data
*
* @param {Object} params - Arg
* @param {Object} params.request - Http request object
* @param {http.IncomingMessage} params.request - Http request object
* @param {String} params.encryptionKey - Encryption Key
* @param {String} params.encryptionSalt - Encryption Salt
* @param {String} params.level - Optional. "Deep" value indicates an extra layer of security
@ -130,7 +131,7 @@ function userAuth({ request, encryptionKey, encryptionSalt, level, database }) {
return {
success: false,
payload: null,
msg: error.message,
msg: error,
};
}
}

View File

@ -1,8 +1,11 @@
// @ts-check
/**
* ==============================================================================
* Imports
* ==============================================================================
*/
const http = require("http");
/**
* Parse request cookies
@ -13,9 +16,9 @@
* @async
*
* @param {object} params - main params object
* @param {object} params.request - HTTPS request object
* @param {http.IncomingMessage} params.request - HTTPS request object
*
* @returns {object|null}
* @returns {* | null}
*/
module.exports = function ({ request }) {
/**
@ -28,7 +31,7 @@ module.exports = function ({ request }) {
////////////////////////////////////////
////////////////////////////////////////
/** @type {string|null} */
/** @type {string | undefined} */
const cookieString = request.headers.cookie;
if (!cookieString || typeof cookieString !== "string") {