Compare commits

..

No commits in common. "0ed130f7b88f0baf0486887d80fcd8fbf65e657d" and "a992868eb68e48ec777da075690e59a81bd54550" have entirely different histories.

2 changed files with 1 additions and 53 deletions

View File

@ -118,15 +118,7 @@ async function getAllCategory(res: Response): Promise<Response> {
});
}
/**
* Get category by slug
*
* @param {Request} req - The request object containing category slug
* @param {Response} res - The response object to send back the category
*
* @return {Promise<Response>} - The response with category data or error message
*/
async function getBySlugCategory(req: Request, res:Response): Promise<Response> {
async function getBySlugCategory(req: Request, res:Response) {
const categorySlug = req.params["categorySlug"];
if (!categorySlug) {
logger.error("Category slug is missing");

View File

@ -348,50 +348,6 @@ const MySqlService = {
reject(err as Error);
}
})
},
/**
* Fetches a category by its Id
*
* @param {MysqlHandler} handler - The instance of the MysqlHandler used for executing the query
* @param {string} brandId - The Id of the category to be fetched
* @return {Promise<IDbBrand>} - A promise that, when resolved, returns the category matching the Id
* @throws {Error} - If an error occurs during execution
* @throws {string} - If brandId is undefined or invalid
*/
getById(handler: MysqlHandler, brandId: string): Promise<IDbBrand> {
return new Promise((resolve, reject) => {
if (!brandId) return reject('slug is undefined')
if (brandId.length !== 36) return reject('Id invalid');
const _sql = "SELECT * FROM `brands` WHERE `id` = ?";
const _values = [brandId];
try {
resolve(handler.execute(_sql, _values) as unknown as IDbBrand);
} catch (err: unknown) {
//TODO Reject with null and logger error
reject(err as Error);
}
})
},
/**
* Retrieves a brand from the database by its slug.
*
* @param {MysqlHandler} handler - The MySQL handler object used to connect to the database.
* @param {string} brandSlug - The slug of the brand to retrieve.
* @returns {Promise<IDbBrand>} - A promise that resolves with the brand object if found, or rejects with an error message.
*/
getBySlug(handler: MysqlHandler, brandSlug: string): Promise<IDbBrand> {
return new Promise((resolve, reject) => {
if (!brandSlug) return reject('slug is undefined')
const _sql = "SELECT * FROM `brands` WHERE `slug_name` = ?";
const _values = [brandSlug];
try {
resolve(handler.execute(_sql, _values) as unknown as IDbBrand);
} catch (err: unknown) {
reject(err as Error);
}
})
}
},
Model: {