@@ -7,23 +7,15 @@ import createGetOrCreateSession from './getOrCreateSession';
77const sessionRouter = Router ( ) ;
88const videoService = createVideoService ( ) ;
99const sessionService = getSessionStorageService ( ) ;
10- const getOrCreateSession = createGetOrCreateSession ( {
11- videoService,
12- sessionService,
13- } ) ;
10+ const getOrCreateSession = createGetOrCreateSession ( { videoService, sessionService } ) ;
1411
1512sessionRouter . get ( '/:room' , async ( req : Request < { room : string } > , res : Response ) => {
1613 try {
1714 const { room : roomName } = req . params ;
1815 const sessionId = await getOrCreateSession ( roomName ) ;
1916 const data = videoService . generateToken ( sessionId ) ;
2017 const captionsId = await sessionService . getCaptionsId ( roomName ) ;
21- res . json ( {
22- sessionId,
23- token : data . token ,
24- apiKey : data . apiKey ,
25- captionsId,
26- } ) ;
18+ res . json ( { sessionId, token : data . token , apiKey : data . apiKey , captionsId } ) ;
2719 } catch ( error : unknown ) {
2820 const message = error instanceof Error ? error . message : error ;
2921 res . status ( 500 ) . send ( { message } ) ;
@@ -36,15 +28,12 @@ sessionRouter.post('/:room/startArchive', async (req: Request<{ room: string }>,
3628 const sessionId = await sessionService . getSession ( roomName ) ;
3729 if ( sessionId ) {
3830 const archive = await videoService . startArchive ( roomName , sessionId ) ;
39- res . json ( {
40- archiveId : archive . id ,
41- status : 200 ,
42- } ) ;
31+ res . json ( { archiveId : archive . id , status : 200 } ) ;
4332 } else {
4433 res . status ( 404 ) . json ( { message : 'Room not found' } ) ;
4534 }
4635 } catch ( error : unknown ) {
47- console . log ( error ) ;
36+ console . error ( error ) ;
4837 const errorMessage = error instanceof Error ? error . message : 'Unknown error occurred' ;
4938 res . status ( 500 ) . json ( { message : errorMessage } ) ;
5039 }
@@ -57,10 +46,7 @@ sessionRouter.post(
5746 const { archiveId } = req . params ;
5847 if ( archiveId ) {
5948 const responseArchiveId = await videoService . stopArchive ( archiveId ) ;
60- res . json ( {
61- archiveId : responseArchiveId ,
62- status : 200 ,
63- } ) ;
49+ res . json ( { archiveId : responseArchiveId , status : 200 } ) ;
6450 }
6551 } catch ( error : unknown ) {
6652 res . status ( 500 ) . send ( { message : ( error as Error ) . message ?? error } ) ;
@@ -74,10 +60,7 @@ sessionRouter.get('/:room/archives', async (req: Request<{ room: string }>, res:
7460 const sessionId = await sessionService . getSession ( roomName ) ;
7561 if ( sessionId ) {
7662 const archives = await videoService . listArchives ( sessionId ) ;
77- res . json ( {
78- archives,
79- status : 200 ,
80- } ) ;
63+ res . json ( { archives, status : 200 } ) ;
8164 } else {
8265 res . status ( 404 ) . json ( { message : 'Room not found' } ) ;
8366 }
@@ -109,10 +92,7 @@ sessionRouter.post(
10992 } else {
11093 // the captions were already enabled for this room
11194 const captionsId = await sessionService . getCaptionsId ( roomName ) ;
112- res . json ( {
113- captionsId,
114- status : 200 ,
115- } ) ;
95+ res . json ( { captionsId, status : 200 } ) ;
11696 }
11797 } catch ( error : unknown ) {
11898 const errorMessage = error instanceof Error ? error . message : 'Unknown error occurred' ;
@@ -148,15 +128,9 @@ sessionRouter.post(
148128 if ( captionsUserCount === 0 ) {
149129 const disableResponse = await videoService . disableCaptions ( captionsId ) ;
150130 await sessionService . setCaptionsId ( roomName , '' ) ;
151- res . json ( {
152- disableResponse,
153- status : 200 ,
154- } ) ;
131+ res . json ( { disableResponse, status : 200 } ) ;
155132 } else {
156- res . json ( {
157- disableResponse : 'Captions are still active for other users' ,
158- status : 200 ,
159- } ) ;
133+ res . json ( { disableResponse : 'Captions are still active for other users' , status : 200 } ) ;
160134 }
161135 } catch ( error : unknown ) {
162136 const errorMessage = error instanceof Error ? error . message : 'Unknown error occurred' ;
0 commit comments