Skip to content

Commit

Permalink
fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Victor committed Aug 5, 2022
1 parent 393ac14 commit b2ac998
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 5 deletions.
1 change: 1 addition & 0 deletions src/fixtures/controllers/fixturesController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ export const findFixtures = catchAsync(
res.status(200).json({
message: 'Fixtures fetched successfully',
status: 'success',
results: data.length,
data,
});
}
Expand Down
2 changes: 1 addition & 1 deletion src/fixtures/services/fixturesService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ export const remove = async (
)}`
);

const team = await FixtureModel.findOne({ id, isDeleted: false });
const team = await FixtureModel.findOne({ _id: id, isDeleted: false });

if (!team) {
throw new AppError('No fixture found with that ID or already deleted', 404);
Expand Down
4 changes: 3 additions & 1 deletion src/routes/fixtureRouter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import {
createFixtures,
findFixtureById,
findFixtures,
removeFixture,
updateFixture,
} from '../fixtures/controllers/fixturesController';
import { protect, restrictTo } from '../middlewares';
Expand All @@ -18,6 +19,7 @@ router
router
.route('/:id')
.get(restrictTo('admin', 'user'), findFixtureById)
.patch(restrictTo('admin'), updateFixture);
.patch(restrictTo('admin'), updateFixture)
.delete(restrictTo('admin'), removeFixture);

export default router;
4 changes: 2 additions & 2 deletions src/routes/teamRouter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { cleanCache, protect, restrictTo } from '../middlewares';

import {
createTeam,
findTeamAllTeams,
findAllTeams,
findTeamById,
removeTeam,
updateTeam,
Expand All @@ -16,7 +16,7 @@ router.use(protect);
router
.route('/')
.post(restrictTo('admin'), cleanCache, createTeam)
.get(restrictTo('admin', 'user'), findTeamAllTeams);
.get(restrictTo('admin', 'user'), findAllTeams);
router
.route('/:id')
.get(restrictTo('admin', 'user'), findTeamById)
Expand Down
3 changes: 2 additions & 1 deletion src/team/controllers/teamController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,14 @@ export const createTeam = catchAsync(
}
);

export const findTeamAllTeams = catchAsync(
export const findAllTeams = catchAsync(
async (req: Request, res: Response, next: NextFunction): Promise<void> => {
const data = await find();

res.status(200).json({
message: 'Teams fetched successfully',
status: 'success',
results: data.length,
data,
});
}
Expand Down

0 comments on commit b2ac998

Please sign in to comment.