Upload files to "/"

This commit is contained in:
Sven Minio 2026-05-17 12:39:25 +02:00
commit 1fa6d558c7
149 changed files with 27987 additions and 0 deletions

35
dist/modules/http/get.d.ts vendored Normal file
View file

@ -0,0 +1,35 @@
/**
* @file src/modules/http/get.ts
* @version 2.0.6
* @since 2.0.0
* @license GPL-3.0-or-later
* @copyright Sven Minio 2026
* @author Sven Minio <https://sven-minio.de>
* @category HTTP
* @description
* * Abstraction for HTTP GET requests.
*/
/**
* * Performs an asynchronous HTTP GET request and expects a JSON response. Includes an automatic timeout of 5000ms to avoid hanging requests.
* @example const data = await get<UserData>('/api/user/1'); => Fetches user data from the specified endpoint and parses it as JSON.
* @example const data = await get('/api/user/1', { signal: customAbortSignal }); => Fetches user data with a custom abort signal for cancellation.
* @template T The expected type of the response data (Generic).
* @param url The target URL for the request.
* @param option Optional RequestInit object to customize the fetch request.
* @returns A Promise resolving with the typed JSON data.
* @throws Error if HTTP status is not in success range (200-299) or a timeout occurs.
*/
export declare function get<T>(url: string, option?: RequestInit): Promise<T>;
/**
* * Performs an asynchronous HTTP GET request and returns the raw text content. Ideal for loading HTML fragments (Server-Side Rendering Partials) or plain text.
* @example const html = await getText('/templates/modal.html'); => Fetches an HTML template as a string for later insertion into the DOM.
* @example const text = await getText('/api/status'); => Fetches a plain text status message from the server.
* @example const html = await getText('/templates/modal.html', { signal: customAbortSignal }); => Fetches an HTML template with a custom abort signal for cancellation.
* @template T The expected type of the response data (Generic, defaults to string).
* @param url The target URL for the request.
* @param option Optional RequestInit object to customize the fetch request.
* @returns A Promise containing the response body as a string.
* @throws Error if HTTP status is not in success range (200-299).
*/
export declare function getText<T = string>(url: string, option?: RequestInit): Promise<T>;
//# sourceMappingURL=get.d.ts.map

1
dist/modules/http/get.d.ts.map vendored Normal file
View file

@ -0,0 +1 @@
{"version":3,"file":"get.d.ts","sourceRoot":"","sources":["../../../src/modules/http/get.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH;;;;;;;;;GASG;AACH,wBAAsB,GAAG,CAAC,CAAC,EAAE,GAAG,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,CAAC,CAAC,CAoB1E;AAED;;;;;;;;;;GAUG;AACH,wBAAsB,OAAO,CAAC,CAAC,GAAG,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,CAAC,CAAC,CAoBvF"}

27
dist/modules/http/index.d.ts vendored Normal file
View file

@ -0,0 +1,27 @@
/**
* @file src/modules/http/index.ts
* @version 2.1.0
* @since 2.0.0
* @license GPL-3.0-or-later
* @copyright Sven Minio 2026
* @author Sven Minio <https://sven-minio.de>
* @category HTTP
* @description
* * Central entry point for HTTP requests. Aggregates GET and POST methods.
* @requires ./get
* * HTTP GET methods (get, getText).
* @requires ./post
* * HTTP POST methods.
* @requires ./upload
* * HTTP file upload method with progress tracking.
*/
/**
* * The central HTTP client of the framework. Aggregates all HTTP methods (GET, POST, etc.) into a unified interface. Acts as a wrapper around the native `fetch` API to simplify JSON parsing, error handling, and typing.
*/
export declare const http: {
upload<T>(url: string, data: FormData | File, onProgress?: (percentage: number, loaded: number, total: number) => void): Promise<T>;
post<T>(url: string, body?: any, option?: RequestInit): Promise<T>;
get<T>(url: string, option?: RequestInit): Promise<T>;
getText<T = string>(url: string, option?: RequestInit): Promise<T>;
};
//# sourceMappingURL=index.d.ts.map

1
dist/modules/http/index.d.ts.map vendored Normal file
View file

@ -0,0 +1 @@
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/modules/http/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAMH;;GAEG;AACH,eAAO,MAAM,IAAI;;;;;CAIhB,CAAC"}

23
dist/modules/http/post.d.ts vendored Normal file
View file

@ -0,0 +1,23 @@
/**
* @file src/modules/http/post.ts
* @version 2.0.5
* @since 2.0.2
* @license GPL-3.0-or-later
* @copyright Sven Minio 2026
* @author Sven Minio <https://sven-minio.de>
* @category HTTP
* * @description
* * Abstraction for HTTP POST requests.
*/
/**
* * Performs an asynchronous HTTP POST request to the specified URL. Automatically sets the 'Content-Type' header to 'application/json' and serializes the body.
* @example const response = await post('/api/login', { username: 'user', password: 'pass' });
* @template T The expected response type (Generic).
* @param url The target URL for the request.
* @param body The data to send (automatically JSON serialized). Default is {}.
* @param option Optional RequestInit object to customize the fetch request.
* @returns A Promise resolving with the deserialized JSON response of type T.
* @throws Error if the HTTP status code is not in the range 200-299.
*/
export declare function post<T>(url: string, body?: any, option?: RequestInit): Promise<T>;
//# sourceMappingURL=post.d.ts.map

1
dist/modules/http/post.d.ts.map vendored Normal file
View file

@ -0,0 +1 @@
{"version":3,"file":"post.d.ts","sourceRoot":"","sources":["../../../src/modules/http/post.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH;;;;;;;;;GASG;AACH,wBAAsB,IAAI,CAAC,CAAC,EAAE,GAAG,EAAE,MAAM,EAAE,IAAI,GAAE,GAAQ,EAAE,MAAM,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,CAAC,CAAC,CA6B3F"}

30
dist/modules/http/upload.d.ts vendored Normal file
View file

@ -0,0 +1,30 @@
/**
* @file src/modules/http/upload.ts
* @version 2.0.0
* @since 2.3.0
* @license GPL-3.0-or-later
* @copyright Sven Minio 2026
* @author Sven Minio <https://sven-minio.de>
* @category HTTP
* * @description
* * Abstraction for HTTP POST requests.
*/
/**
* * Performs a multipart/form-data upload with precise progress tracking.
* * Uses XMLHttpRequest under the hood because the native Fetch API lacks upload progress support.
* @example
* const fileInput = $('input[type="file"]')[0] as HTMLInputElement;
* if (fileInput && fileInput.files?.length) {
* await $.http.upload('/upload', fileInput.files[0], (percentage) => {
* // Update a progress bar using jBase
* $('#progress-bar').css('width', `${percentage}%`);
* });
* }
* @template T The expected response type (Generic).
* @param url The target endpoint.
* @param data A FormData object or a single File.
* @param onProgress Optional callback receiving the progress percentage (0-100), loaded bytes, and total bytes.
* @returns A Promise resolving to the parsed JSON response.
*/
export declare function upload<T>(url: string, data: FormData | File, onProgress?: (percentage: number, loaded: number, total: number) => void): Promise<T>;
//# sourceMappingURL=upload.d.ts.map

1
dist/modules/http/upload.d.ts.map vendored Normal file
View file

@ -0,0 +1 @@
{"version":3,"file":"upload.d.ts","sourceRoot":"","sources":["../../../src/modules/http/upload.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAsB,MAAM,CAAC,CAAC,EAAE,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,QAAQ,GAAG,IAAI,EAAE,UAAU,CAAC,EAAE,CAAC,UAAU,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,KAAK,IAAI,GAAG,OAAO,CAAC,CAAC,CAAC,CAoCxJ"}