Skip to content

Commit

Permalink
fix typo in LEVEL_UP_LOCATION (#139)
Browse files Browse the repository at this point in the history
  • Loading branch information
fuxingloh authored Jun 7, 2021
1 parent 656668d commit 5b07dd6
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
1 change: 1 addition & 0 deletions apps/whale/src/app.configuration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
* replacing the config module.
*/
export const AppConfiguration = (): any => ({
isProd: process.env.NODE_ENV === 'production',
defid: {
url: process.env.WHALE_DEFID_URL
},
Expand Down
13 changes: 9 additions & 4 deletions apps/whale/src/module.database/provider.level/module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,16 @@ function mkdir (location: string): void {
providers: [
{
provide: 'LEVEL_UP_LOCATION',
/**
* if isProd, resolve to .leveldb/{network}
* else, resolve to .leveldb/{network}/time-now
*/
useFactory: (configService: ConfigService): string => {
const location = configService.get(
'database.level.location',
process.env.NODE_ENV === 'production ' ? '.level/index' : `.level/unnamed/${Date.now()}`
)
const isProd = configService.get<boolean>('isProd', false)
const network = configService.get<string>('network', 'unknown')
const defaultLocation = isProd ? `.leveldb/${network}` : `.leveldb/${network}/${Date.now()}`

const location = configService.get('database.level.location', defaultLocation)
mkdir(location)
return location
},
Expand Down

0 comments on commit 5b07dd6

Please sign in to comment.