import passportJwtMiddleware from '../security/passportJwtMiddleware' ; import { Get , JsonController , NotFoundError , Param , UseBefore } from 'routing-controllers' ; import { errorCodes } from '../config/errorCodes' ; import { ChatRoom } from '../models/ChatRoom' ; @ JsonController ( '/chatRoom' ) @ UseBefore ( passportJwtMiddleware ) export default class ChatRoomController { api apiName apiGroup apiParam apiSuccess apiSuccessExample @ Get ( '/:id([a-fA-F0-9]{24})' ) async getChatRoom ( @ Param ( 'id' ) id ) { const chatRoom = await ChatRoom . findById ( id ) ; if ( ! chatRoom ) { throw new NotFoundError ( errorCodes . chat . roomNotFound . text ) ; } return chatRoom . toObject ( ) ; } }