-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #437 from Alt-Org/change/environment-var-414
add environment variable to env vars
- Loading branch information
Showing
13 changed files
with
471 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,110 @@ | ||
import {SessionStage} from "../../../../box/enum/SessionStage.enum"; | ||
import {Box} from "../../../../box/schemas/box.schema"; | ||
import {ObjectId} from "mongodb"; | ||
import {Tester} from "../../../../box/schemas/tester.schema"; | ||
import {DailyTask} from "../../../../dailyTasks/dailyTasks.schema"; | ||
|
||
export default class BoxBuilder { | ||
private readonly base: Partial<Box> = { | ||
adminPassword: 'defaultAdminPassword', | ||
sessionStage: SessionStage.PREPARING, | ||
testersSharedPassword: null, | ||
boxRemovalTime: Date.now() + 1000000, | ||
sessionResetTime: Date.now() + 500000, | ||
adminProfile_id: null, | ||
adminPlayer_id: null, | ||
clan_ids: [], | ||
soulHome_ids: [], | ||
room_ids: [], | ||
stock_ids: [], | ||
chat_id: null, | ||
testers: [], | ||
accountClaimersIds: [], | ||
dailyTasks: [], | ||
_id: null | ||
}; | ||
|
||
build(): Box { | ||
return { ...this.base } as Box; | ||
} | ||
|
||
setAdminPassword(password: string) { | ||
this.base.adminPassword = password; | ||
return this; | ||
} | ||
|
||
setSessionStage(stage: SessionStage) { | ||
this.base.sessionStage = stage; | ||
return this; | ||
} | ||
|
||
setTestersSharedPassword(password: string | null) { | ||
this.base.testersSharedPassword = password; | ||
return this; | ||
} | ||
|
||
setBoxRemovalTime(time: number) { | ||
this.base.boxRemovalTime = time; | ||
return this; | ||
} | ||
|
||
setSessionResetTime(time: number) { | ||
this.base.sessionResetTime = time; | ||
return this; | ||
} | ||
|
||
setAdminProfileId(profileId: ObjectId) { | ||
this.base.adminProfile_id = profileId; | ||
return this; | ||
} | ||
|
||
setAdminPlayerId(playerId: ObjectId) { | ||
this.base.adminPlayer_id = playerId; | ||
return this; | ||
} | ||
|
||
setClanIds(clanIds: ObjectId[]) { | ||
this.base.clan_ids = clanIds; | ||
return this; | ||
} | ||
|
||
setSoulHomeIds(soulHomeIds: ObjectId[]) { | ||
this.base.soulHome_ids = soulHomeIds; | ||
return this; | ||
} | ||
|
||
setRoomIds(roomIds: ObjectId[]) { | ||
this.base.room_ids = roomIds; | ||
return this; | ||
} | ||
|
||
setStockIds(stockIds: ObjectId[]) { | ||
this.base.stock_ids = stockIds; | ||
return this; | ||
} | ||
|
||
setChatId(chatId: ObjectId) { | ||
this.base.chat_id = chatId; | ||
return this; | ||
} | ||
|
||
setTesters(testers: Tester[]) { | ||
this.base.testers = testers; | ||
return this; | ||
} | ||
|
||
setAccountClaimersIds(accountClaimersIds: string[]) { | ||
this.base.accountClaimersIds = accountClaimersIds; | ||
return this; | ||
} | ||
|
||
setDailyTasks(dailyTasks: DailyTask[]) { | ||
this.base.dailyTasks = dailyTasks; | ||
return this; | ||
} | ||
|
||
setId(id: ObjectId) { | ||
this.base._id = id; | ||
return this; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,105 @@ | ||
import {SessionStage} from "../../../../box/enum/SessionStage.enum"; | ||
import {ObjectId} from "mongodb"; | ||
import {Tester} from "../../../../box/schemas/tester.schema"; | ||
import {DailyTask} from "../../../../dailyTasks/dailyTasks.schema"; | ||
import {CreateBoxDto} from "../../../../box/dto/createBox.dto"; | ||
|
||
|
||
export default class CreateBoxDtoBuilder { | ||
private readonly base: Partial<CreateBoxDto> = { | ||
adminPassword: 'defaultAdminPassword', | ||
sessionStage: SessionStage.PREPARING, | ||
testersSharedPassword: null, | ||
boxRemovalTime: Date.now() + 1000000, | ||
sessionResetTime: Date.now() + 500000, | ||
adminProfile_id: null, | ||
adminPlayer_id: null, | ||
clan_ids: [], | ||
soulHome_ids: [], | ||
room_ids: [], | ||
stock_ids: [], | ||
chat_id: null, | ||
testers: [], | ||
accountClaimersIds: [], | ||
dailyTasks: [], | ||
}; | ||
|
||
build(): CreateBoxDto { | ||
return { ...this.base } as CreateBoxDto; | ||
} | ||
|
||
setAdminPassword(password: string) { | ||
this.base.adminPassword = password; | ||
return this; | ||
} | ||
|
||
setSessionStage(stage: SessionStage) { | ||
this.base.sessionStage = stage; | ||
return this; | ||
} | ||
|
||
setTestersSharedPassword(password: string | null) { | ||
this.base.testersSharedPassword = password; | ||
return this; | ||
} | ||
|
||
setBoxRemovalTime(time: number) { | ||
this.base.boxRemovalTime = time; | ||
return this; | ||
} | ||
|
||
setSessionResetTime(time: number) { | ||
this.base.sessionResetTime = time; | ||
return this; | ||
} | ||
|
||
setAdminProfileId(profileId: ObjectId) { | ||
this.base.adminProfile_id = profileId; | ||
return this; | ||
} | ||
|
||
setAdminPlayerId(playerId: ObjectId) { | ||
this.base.adminPlayer_id = playerId; | ||
return this; | ||
} | ||
|
||
setClanIds(clanIds: ObjectId[]) { | ||
this.base.clan_ids = clanIds; | ||
return this; | ||
} | ||
|
||
setSoulHomeIds(soulHomeIds: ObjectId[]) { | ||
this.base.soulHome_ids = soulHomeIds; | ||
return this; | ||
} | ||
|
||
setRoomIds(roomIds: ObjectId[]) { | ||
this.base.room_ids = roomIds; | ||
return this; | ||
} | ||
|
||
setStockIds(stockIds: ObjectId[]) { | ||
this.base.stock_ids = stockIds; | ||
return this; | ||
} | ||
|
||
setChatId(chatId: ObjectId) { | ||
this.base.chat_id = chatId; | ||
return this; | ||
} | ||
|
||
setTesters(testers: Tester[]) { | ||
this.base.testers = testers; | ||
return this; | ||
} | ||
|
||
setAccountClaimersIds(accountClaimersIds: string[]) { | ||
this.base.accountClaimersIds = accountClaimersIds; | ||
return this; | ||
} | ||
|
||
setDailyTasks(dailyTasks: DailyTask[]) { | ||
this.base.dailyTasks = dailyTasks; | ||
return this; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import {ObjectId} from "mongodb"; | ||
import {GroupAdmin} from "../../../../box/schemas/groupAdmin.schema"; | ||
|
||
export default class GroupAdminBuilder { | ||
private readonly base: Partial<GroupAdmin> = { | ||
password: 'defaultPassword', | ||
_id: null, | ||
}; | ||
|
||
build(): GroupAdmin { | ||
return { ...this.base } as GroupAdmin; | ||
} | ||
|
||
setPassword(password: string) { | ||
this.base.password = password; | ||
return this; | ||
} | ||
|
||
setId(id: ObjectId) { | ||
this.base._id = id; | ||
return this; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,111 @@ | ||
import {UpdateBoxDto} from "../../../../box/dto/updateBox.dto"; | ||
import {SessionStage} from "../../../../box/enum/SessionStage.enum"; | ||
import {ObjectId} from "mongodb"; | ||
import {Tester} from "../../../../box/schemas/tester.schema"; | ||
import {DailyTask} from "../../../../dailyTasks/dailyTasks.schema"; | ||
|
||
|
||
export default class UpdateBoxDtoBuilder { | ||
private readonly base: Partial<UpdateBoxDto> = { | ||
_id: null, | ||
adminPassword: null, | ||
sessionStage: null, | ||
testersSharedPassword: null, | ||
boxRemovalTime: null, | ||
sessionResetTime: null, | ||
adminProfile_id: null, | ||
adminPlayer_id: null, | ||
clan_ids: null, | ||
soulHome_ids: null, | ||
room_ids: null, | ||
stock_ids: null, | ||
chat_id: null, | ||
testers: null, | ||
accountClaimersIds: null, | ||
dailyTasks: null, | ||
}; | ||
|
||
build(): UpdateBoxDto { | ||
return { ...this.base } as UpdateBoxDto; | ||
} | ||
|
||
setId(id: string) { | ||
this.base._id = id; | ||
return this; | ||
} | ||
|
||
setAdminPassword(password: string) { | ||
this.base.adminPassword = password; | ||
return this; | ||
} | ||
|
||
setSessionStage(stage: SessionStage) { | ||
this.base.sessionStage = stage; | ||
return this; | ||
} | ||
|
||
setTestersSharedPassword(password: string | null) { | ||
this.base.testersSharedPassword = password; | ||
return this; | ||
} | ||
|
||
setBoxRemovalTime(time: number) { | ||
this.base.boxRemovalTime = time; | ||
return this; | ||
} | ||
|
||
setSessionResetTime(time: number) { | ||
this.base.sessionResetTime = time; | ||
return this; | ||
} | ||
|
||
setAdminProfileId(profileId: ObjectId) { | ||
this.base.adminProfile_id = profileId; | ||
return this; | ||
} | ||
|
||
setAdminPlayerId(playerId: ObjectId) { | ||
this.base.adminPlayer_id = playerId; | ||
return this; | ||
} | ||
|
||
setClanIds(clanIds: ObjectId[]) { | ||
this.base.clan_ids = clanIds; | ||
return this; | ||
} | ||
|
||
setSoulHomeIds(soulHomeIds: ObjectId[]) { | ||
this.base.soulHome_ids = soulHomeIds; | ||
return this; | ||
} | ||
|
||
setRoomIds(roomIds: ObjectId[]) { | ||
this.base.room_ids = roomIds; | ||
return this; | ||
} | ||
|
||
setStockIds(stockIds: ObjectId[]) { | ||
this.base.stock_ids = stockIds; | ||
return this; | ||
} | ||
|
||
setChatId(chatId: ObjectId) { | ||
this.base.chat_id = chatId; | ||
return this; | ||
} | ||
|
||
setTesters(testers: Tester[]) { | ||
this.base.testers = testers; | ||
return this; | ||
} | ||
|
||
setAccountClaimersIds(accountClaimersIds: string[]) { | ||
this.base.accountClaimersIds = accountClaimersIds; | ||
return this; | ||
} | ||
|
||
setDailyTasks(dailyTasks: DailyTask[]) { | ||
this.base.dailyTasks = dailyTasks; | ||
return this; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import BoxBuilder from "./box/BoxBuilder"; | ||
import CreateBoxDtoBuilder from "./box/CreateBoxDtoBuilder"; | ||
import UpdateBoxDtoBuilder from "./box/UpdateBoxDtoBuilder"; | ||
import GroupAdminBuilder from "./box/GroupAdminBuilder"; | ||
|
||
|
||
type BuilderName = 'Box' | 'CreateBoxDto' | 'UpdateBoxDto' | 'GroupAdmin'; | ||
|
||
type BuilderMap = { | ||
Box: BoxBuilder, | ||
CreateBoxDto: CreateBoxDtoBuilder, | ||
UpdateBoxDto: UpdateBoxDtoBuilder, | ||
GroupAdmin: GroupAdminBuilder | ||
}; | ||
|
||
export default class BoxBuilderFactory { | ||
static getBuilder<T extends BuilderName>(builderName: T): BuilderMap[T] { | ||
switch (builderName) { | ||
case 'Box': | ||
return new BoxBuilder() as BuilderMap[T]; | ||
case 'CreateBoxDto': | ||
return new CreateBoxDtoBuilder() as BuilderMap[T]; | ||
case 'UpdateBoxDto': | ||
return new UpdateBoxDtoBuilder() as BuilderMap[T]; | ||
case 'GroupAdmin': | ||
return new GroupAdminBuilder() as BuilderMap[T]; | ||
default: | ||
throw new Error(`Unknown builder name: ${builderName}`); | ||
} | ||
} | ||
} |
Oops, something went wrong.