From 0005ba7dc9e12740735aa3503b84ba097f926023 Mon Sep 17 00:00:00 2001 From: Scott Idem Date: Thu, 23 May 2024 18:59:50 -0400 Subject: [PATCH] Code clean up --- src/lib/api.ts | 14 +++++++------- src/lib/api_get_object.ts | 13 ++++++++++++- src/lib/api_post_object.ts | 11 ++++++++++- 3 files changed, 29 insertions(+), 9 deletions(-) diff --git a/src/lib/api.ts b/src/lib/api.ts index 554a31c8..cd897dd0 100644 --- a/src/lib/api.ts +++ b/src/lib/api.ts @@ -1,11 +1,11 @@ // Aether API Library (TS) -// This is intended to be used with the Aether API. +// This is intended to be used with the Aether API. The goal is to just import all of the core functions and re-export them as a single module. This is to make it easier to import the functions into other modules. // This needs to be cleaned up and ideally removed the need for Axios. -import { delete_object } from './api_delete_object'; -import { get_object } from './api_get_object'; -import { patch_object } from './api_patch_object'; -import { post_object } from './api_post_object'; +import { delete_object } from './api_delete_object'; // Exported at the end of this file +import { get_object } from './api_get_object'; // Exported at the end of this file +import { patch_object } from './api_patch_object'; // Exported at the end of this file +import { post_object } from './api_post_object'; // Exported at the end of this file // Updated 2023-12-01 @@ -926,11 +926,11 @@ export let send_email = async function send_email({api_cfg, from_email, from_nam /* END: Utility: Email Related */ -function resolved(result) { +function resolved(result: any) { console.log('Resolved'); } -function rejected(result) { +function rejected(result: any) { console.error(result); } diff --git a/src/lib/api_get_object.ts b/src/lib/api_get_object.ts index 4754fcb9..4ce2ad2d 100644 --- a/src/lib/api_get_object.ts +++ b/src/lib/api_get_object.ts @@ -1,5 +1,7 @@ import axios from 'axios'; +import type { key_val } from '$lib/ae_stores'; + export let temp_get_blob_percent_completed = 0; // export let get_blob_percent_completed = readable(temp_get_blob_percent_completed); export let get_blob_percent_completed = temp_get_blob_percent_completed; @@ -74,7 +76,7 @@ export let get_object = async function get_object( } // console.log('Clean the headers. No _underscores_!') - let headers_cleaned = {}; + let headers_cleaned: key_val = {}; for (const prop in headers) { // No underscores allowed in the header parameters! let prop_cleaned = prop.replaceAll('_', '-'); @@ -340,3 +342,12 @@ export let get_object = async function get_object( } } } + + +function resolved(result: any) { + console.log('Resolved'); +} + +function rejected(result: any) { + console.error(result); +} \ No newline at end of file diff --git a/src/lib/api_post_object.ts b/src/lib/api_post_object.ts index fb201f19..6933b7cf 100644 --- a/src/lib/api_post_object.ts +++ b/src/lib/api_post_object.ts @@ -145,7 +145,7 @@ export let post_object = async function post_object( ); console.log('POST Blob Progress:', progressEvent.progress, 'Total:', progressEvent.total, 'Loaded:', progressEvent.loaded, 'Percent Completed', percent_completed); - temp_get_blob_percent_completed = percent_completed; + temp_post_blob_percent_completed = percent_completed; } } ) @@ -193,3 +193,12 @@ export let post_object = async function post_object( } } } + + +function resolved(result: any) { + console.log('Resolved'); +} + +function rejected(result: any) { + console.error(result); +} \ No newline at end of file