-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: implement first steps of create category endpoint
- Loading branch information
Showing
3 changed files
with
36 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import { NextFunction, Request, Response } from "express"; | ||
|
||
import { ServerErrorMessage, ValidationErrorMessage } from "../../constants"; | ||
import getCustomValidationResults from "../../helpers/get-validation-results"; | ||
import CustomError from "../../utils/custom-error"; | ||
|
||
export const createCategory = async ( | ||
request: Request, | ||
response: Response, | ||
next: NextFunction, | ||
) => { | ||
try { | ||
const validationErrors = getCustomValidationResults(request); | ||
|
||
if (validationErrors) { | ||
const error = new CustomError( | ||
ValidationErrorMessage, | ||
400, | ||
validationErrors, | ||
); | ||
return next(error); | ||
} | ||
|
||
response.status(400).json({ message: "😭💔💀" }); | ||
} catch { | ||
const error = new CustomError(ServerErrorMessage); | ||
next(error); | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
export * as adminAuthController from "./admin-auth.controller"; | ||
export * as userAuthController from "./user-auth.controller"; | ||
export * as adminController from "./admin.controller"; | ||
export * as clientsController from "./admin/clients.controler"; | ||
export * as categoriesController from "./admin/categories.controller"; |