Skip to content

Commit

Permalink
Merge pull request #104 from Noorin99/Noorin99/issue100
Browse files Browse the repository at this point in the history
Fix bugs
  • Loading branch information
nurabunamus authored Aug 8, 2023
2 parents 1fd77b9 + 65b98ea commit 672931e
Show file tree
Hide file tree
Showing 7 changed files with 35 additions and 15 deletions.
4 changes: 0 additions & 4 deletions src/docs/admin.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -74,10 +74,6 @@ components:
type: string
role:
type: string
paymentMethod:
type: array
items:
$ref: '#/components/schemas/PaymentMethod'
cookerStatus:
type: string
paymentMethodStatus:
Expand Down
23 changes: 21 additions & 2 deletions src/docs/auth.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -277,8 +277,27 @@ components:
Register2Request:
type: object
properties:
address:
$ref: '#/components/schemas/IAddress'
streetName:
type: string
example: Main Street
streetNumber:
type: number
example: 123
flatNumber:
type: number
example: 4
district:
type: string
example: Downtown
city:
type: string
example: New York
state:
type: string
example: NY
zip:
type: number
example: 10001
phone:
type: string
example: '+905342338743'
Expand Down
2 changes: 1 addition & 1 deletion src/docs/order.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ paths:
'500':
description: Internal server error

/api/orders/{id}/cancel:
/api/orders/{orderId}/cancel:
put:
summary: Cancel an order by ID
parameters:
Expand Down
2 changes: 1 addition & 1 deletion src/docs/passwordReset.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ paths:
properties:
token:
type: string
example: 7078782a39fe4fcabeee567772933d44c5ff98600ec343802d2900f43a973515
example: 0a9bb0df7db8c3a96b6a80313245beaa25c97866517b51c4d890040c3c8e89e5
password:
type: string
format: password
Expand Down
2 changes: 1 addition & 1 deletion src/docs/review.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ paths:
type: string
description: The comment about the food item.
example: Delicious!
userId:
customerId:
type: string
description: The ID of the user creating the review.
example: 60f7ea20a8b1c72f9a56c3f2
Expand Down
10 changes: 8 additions & 2 deletions src/middlewares/error-handling.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,15 @@
import { Request, Response } from 'express';
import { NextFunction, Request, Response } from 'express';
import customError from '../errors/customErrors';

const errorHandler = (err: Error, req: Request, res: Response) => {
const errorHandler = (
err: Error,
req: Request,
res: Response,
next: NextFunction
) => {
if (err instanceof customError) {
res.status(err.errorCode).send({ errors: err.serializeErrors() });
next();
} else {
res.send(err);
}
Expand Down
7 changes: 3 additions & 4 deletions src/routes/admin.ts
Original file line number Diff line number Diff line change
@@ -1,20 +1,19 @@
import express from 'express';
import adminController from '../controllers/admin';
import { authenticate } from '../middlewares/authentication';
import checkRole from '../middlewares/authorization';
import { isAuthenticated, checkRole } from '../middlewares/isAuth';

const router = express.Router();

router.get(
'/cooker',
authenticate,
isAuthenticated,
checkRole('admin'),
adminController.getCooker
);

router.get(
'/customers',
authenticate,
isAuthenticated,
checkRole('admin'),
adminController.getCustomers
);
Expand Down

0 comments on commit 672931e

Please sign in to comment.