File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -5,3 +5,4 @@ API_URL=/api
55CORS_ORIGIN = http://localhost:8080
66MONGODB_URI = mongodb://localhost:27017/code-paster
77STATIC_FILES_PATH = " ../../front/dist"
8+ MONGO_EXPIRATION_TIME = ' 2d'
Original file line number Diff line number Diff line change 11export const envConstants = {
2- NODE_ENV : process . env . NODE_ENV ,
3- PORT : process . env . PORT ,
4- isMockRepository : process . env . MOCK_REPOSITORY === 'true' ,
5- MONGODB_URI : process . env . MONGODB_URI ,
6- API_URL : process . env . API_URL ,
7- CORS_ORIGIN : process . env . CORS_ORIGIN ,
8- isProduction : process . env . NODE_ENV === 'production' ,
9- STATIC_FILES_PATH : process . env . STATIC_FILES_PATH
10- } ;
11-
12-
2+ NODE_ENV : process . env . NODE_ENV ,
3+ PORT : process . env . PORT ,
4+ isMockRepository : process . env . MOCK_REPOSITORY === 'true' ,
5+ MONGODB_URI : process . env . MONGODB_URI ,
6+ API_URL : process . env . API_URL ,
7+ CORS_ORIGIN : process . env . CORS_ORIGIN ,
8+ isProduction : process . env . NODE_ENV === 'production' ,
9+ STATIC_FILES_PATH : process . env . STATIC_FILES_PATH ,
10+ MONGO_EXPIRATION_TIME : process . env . MONGO_EXPIRATION_TIME ,
11+ } ;
Original file line number Diff line number Diff line change 11import { Document , model , Schema } from 'mongoose' ;
22import { RoomInfo } from 'dals' ;
3+ import { envConstants } from 'core' ;
34
45const roomSchema = new Schema ( {
56 room : Schema . Types . String ,
6- content : Schema . Types . String
7+ content : Schema . Types . String ,
8+ expireAt : {
9+ type : Schema . Types . Date ,
10+ default : Date . now ,
11+ index : {
12+ expires : envConstants . MONGO_EXPIRATION_TIME ,
13+ } ,
14+ } ,
715} ) ;
816
9- export const RoomContext = model < RoomInfo & Document > (
10- 'RoomInfo' ,
11- roomSchema
12- ) ;
17+ export const RoomContext = model < RoomInfo & Document > ( 'RoomInfo' , roomSchema ) ;
Original file line number Diff line number Diff line change 11import { Document , model , Schema } from 'mongoose' ;
22import { UserSession } from 'dals/session' ;
3+ import { envConstants } from 'core/constants' ;
34
45const userSessionSchema = new Schema ( {
56 room : Schema . Types . String ,
67 trainerToken : Schema . Types . String ,
78 isTrainer : Schema . Types . Boolean ,
8- connectionId : Schema . Types . String
9+ connectionId : Schema . Types . String ,
10+ expireAt : {
11+ type : Schema . Types . Date ,
12+ default : Date . now ,
13+ index : {
14+ expires : envConstants . MONGO_EXPIRATION_TIME ,
15+ } ,
16+ } ,
917} ) ;
1018
1119export const UserSessionContext = model < UserSession & Document > (
You can’t perform that action at this time.
0 commit comments