feat(services): change return type in createCategory function

The return type of the createCategory function in category.service.ts has been changed from unknown to boolean. Now, the function will return true if the creation is successful, and false if an error occurs.

Signed-off-by: Mathis <yidhra@tuta.io>
This commit is contained in:
Mathis H (Avnyr) 2024-04-25 14:11:15 +02:00
parent f3cd6c5985
commit 4a9bc402b4
Signed by: Mathis
GPG Key ID: DD9E0666A747D126

View File

@ -13,20 +13,21 @@ const logger = new Logger({name: 'CategoryService'})
* Creates a new category with the given data.
*
* @param {IDbCategory} data - The category data.
* @returns {Promise<unknown>} A promise that resolves with the created category.
* @returns {Promise<boolean>} A promise that resolves with the created category.
* If an error occurs, the promise will reject with the error.
*/
async function createCategory(data: IDbCategory): Promise<unknown> {
async function createCategory(data: IDbCategory): Promise<boolean> {
logger.info(`Creating a new category... (${data.display_name})`)
try {
return await MysqlService.Category.insert(DbHandler, {
await MysqlService.Category.insert(DbHandler, {
id: uuidv4(),
display_name: data.display_name,
slug_name: data.slug_name
})
return true;
} catch (error) {
logger.error(`Error creating category: ${error}`);
return;
return false;
}
}