File tree Expand file tree Collapse file tree 2 files changed +8
-0
lines changed Expand file tree Collapse file tree 2 files changed +8
-0
lines changed Original file line number Diff line number Diff line change @@ -20,6 +20,9 @@ CLEANUP_INTERVAL=75000
20
20
21
21
JWT_ACCESS_TOKEN_SECRET = <your-jwt-accecss-token>
22
22
23
+ # Lifespan of a room (1 day in milliseconds)
24
+ ROOM_LIFESPAN = 86400000
25
+
23
26
# Copy root .env
24
27
# If using mongoDB containerization, set to true. Else set to false (i.e local testing)
25
28
DB_REQUIRE_AUTH = true
Original file line number Diff line number Diff line change 1
1
import roomModel from "../models/RoomSchema" ;
2
2
import { Request , Response , NextFunction } from "express" ;
3
3
4
+ const ROOM_LIFESPAN = parseInt ( process . env . ROOM_LIFESPAN || "86400000" ) ; // 86400000ms = 1 day
5
+
4
6
export async function getRoomDetails (
5
7
request : Request ,
6
8
response : Response ,
@@ -13,6 +15,9 @@ export async function getRoomDetails(
13
15
if ( ! room ) {
14
16
throw new Error ( "Room not found" ) ;
15
17
}
18
+ if ( Date . now ( ) - room . createdAt . getTime ( ) > ROOM_LIFESPAN ) {
19
+ throw new Error ( "Room has expired" ) ;
20
+ }
16
21
response . status ( 200 ) . json ( {
17
22
roomId,
18
23
attemptStartedAt : room . createdAt . getTime ( ) ,
You can’t perform that action at this time.
0 commit comments