Skip to content

Commit

Permalink
reference teamCommentController in controllers index
Browse files Browse the repository at this point in the history
  • Loading branch information
SimNed committed Sep 9, 2024
1 parent ed755c3 commit 940acbc
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
2 changes: 2 additions & 0 deletions server/controllers/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import { statisticsController } from './statistics';
import { storyController } from './story';
import { studentController } from './student';
import { teacherController } from './teacher';
import { teamCommentController } from './teamComment';
import { userController } from './user';
import { videoController } from './video';
import { villageController } from './village';
Expand Down Expand Up @@ -45,6 +46,7 @@ const controllers = [
studentController,
featureFlagController,
statisticsController,
teamCommentController,
pelicoController,
mediathequeController,
];
Expand Down
9 changes: 4 additions & 5 deletions server/controllers/teamComment.ts
Original file line number Diff line number Diff line change
@@ -1,21 +1,20 @@
import type { NextFunction, Request, Response } from 'express';

import { Comment } from '../entities/comment';
import { TeamComment } from '../entities/teamComment';
import { UserType } from '../entities/user';
import { AppDataSource } from '../utils/data-source';
import { Controller } from './controller';

const commentController = new Controller('/team-comments');
const teamCommentController = new Controller('/team-comments');

// --- Get all comments. ---
commentController.get({ path: '', userType: UserType.ADMIN }, async (req: Request, res: Response) => {
teamCommentController.get({ path: '', userType: UserType.ADMIN }, async (req: Request, res: Response) => {
const teamComments = await AppDataSource.getRepository(TeamComment).find();
res.sendJSON(teamComments);
});

// --- Edit one comment. ---
commentController.put({ path: '/:commentId', userType: UserType.ADMIN }, async (req: Request, res: Response, next: NextFunction) => {
teamCommentController.put({ path: '/:commentId', userType: UserType.ADMIN }, async (req: Request, res: Response, next: NextFunction) => {
const data = req.body;
const id = parseInt(req.params.commentId, 10) ?? 0;
const teamComment = await AppDataSource.getRepository(TeamComment).findOne({ where: { id } });
Expand All @@ -31,4 +30,4 @@ commentController.put({ path: '/:commentId', userType: UserType.ADMIN }, async (
res.sendJSON(updatedTeamComment);
});

export { commentController };
export { teamCommentController };

0 comments on commit 940acbc

Please sign in to comment.