Migration to nuxt 4

Used codemods CLI and reworked most alias'd path that stopped working
This commit is contained in:
Alexis
2025-07-27 14:30:30 +02:00
parent 68b9a38f83
commit 7fdab8601f
280 changed files with 847 additions and 496 deletions

29
app/utils/Regex.ts Normal file
View File

@@ -0,0 +1,29 @@
/**
* Check if the string parses as single digit
*
* @param str String to test
* @returns Result of the test
*/
export function isDigit(str: string) {
return RegExp(/^\d$/g).test(str)
}
/**
* Check if the string parses as an int
*
* @param str String to test
* @returns Result of the test
*/
export function isInt(str: string) {
return RegExp(/^[0-9]*$/g).test(str)
}
/**
* Check if the string parses as a signed int (negative or positive)
*
* @param str String to test
* @returns Result of the test
*/
export function isSignedInt(str: string) {
return RegExp(/^[-+]?[0-9]+$/g).test(str)
}

12
app/utils/Strings.ts Normal file
View File

@@ -0,0 +1,12 @@
/**
* Capitalizes first letters of words in string.
* @param {string} str String to be modified
* @param {boolean=false} lower Whether all other letters should be lowercased
* @return {string}
* @usage
* capitalize('fix this string'); // -> 'Fix This String'
* capitalize('javaSCrIPT'); // -> 'JavaSCrIPT'
* capitalize('javaSCrIPT', true); // -> 'Javascript'
*/
export const capitalize = (str: string, lower: boolean = false) =>
(lower ? str.toLowerCase() : str).replace(/(?:^|\s|["'([{])+\S/g, (match) => match.toUpperCase())

31
app/utils/TryCatch.ts Normal file
View File

@@ -0,0 +1,31 @@
// Types for the result object with discriminated union
type Success<T> = {
data: T;
error: null;
};
type Failure<E> = {
data: null;
error: E;
};
type Result<T, E = Error> = Success<T> | Failure<E>;
/**
* A utility function to handle promises with try-catch
* and return a result object, courtesy of t3.
*
* @param promise The promise to be executed
* @returns A promise that resolves to an object with either the data or the error
* @link https://gist.github.com/t3dotgg/a486c4ae66d32bf17c09c73609dacc5b
*/
export async function tryCatch<T, E = Error>(
promise: Promise<T>,
): Promise<Result<T, E>> {
try {
const data = await promise;
return { data, error: null };
} catch (error) {
return { data: null, error: error as E };
}
}