forked from aeternity/dex-backend
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: move db logic to nest, create ApiModule
- Loading branch information
Showing
24 changed files
with
383 additions
and
112 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,19 @@ | ||
import { Module } from '@nestjs/common'; | ||
import { DatabaseModule } from '../database/database.module'; | ||
import { PairLiquidityInfoHistoryController } from './pair-liquidity-info-history/pair-liquidity-info-history.controller'; | ||
import { PairLiquidityInfoHistoryService } from './pair-liquidity-info-history/pair-liquidity-info-history.service'; | ||
import { PairsController } from './pairs/pairs.controller'; | ||
import { TokensController } from './tokens/tokens.controller'; | ||
import { PairsService } from './pairs/pairs.service'; | ||
import { TokensService } from './tokens/tokens.service'; | ||
|
||
@Module({ | ||
imports: [DatabaseModule], | ||
controllers: [ | ||
PairLiquidityInfoHistoryController, | ||
PairsController, | ||
TokensController, | ||
], | ||
providers: [PairLiquidityInfoHistoryService, PairsService, TokensService], | ||
}) | ||
export class ApiModule {} |
11 changes: 0 additions & 11 deletions
11
src/api/pair-liquidity-info-history/pair-liquidity-info-history.module.ts
This file was deleted.
Oops, something went wrong.
2 changes: 1 addition & 1 deletion
2
src/api/pair-liquidity-info-history/pair-liquidity-info-history.service.ts
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
This file was deleted.
Oops, something went wrong.
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 |
---|---|---|
@@ -1,30 +1,40 @@ | ||
import { Injectable } from '@nestjs/common'; | ||
import * as dal from '../../dal'; | ||
import { presentInvalidTokens } from '../../lib/utils'; | ||
import { PairDbService } from '../../database/pair/pair-db.service'; | ||
|
||
@Injectable() | ||
export class PairsService { | ||
constructor(private readonly pairDbService: PairDbService) {} | ||
async getAllPairs(onlyListed?: boolean) { | ||
return dal.pair.getAll(presentInvalidTokens, onlyListed); | ||
return this.pairDbService.getAllWithCondition( | ||
presentInvalidTokens, | ||
onlyListed, | ||
); | ||
} | ||
|
||
async getAllPairsWithLiquidityInfo(onlyListed?: boolean) { | ||
return dal.pair.getAllWithLiquidityInfo(presentInvalidTokens, onlyListed); | ||
return this.pairDbService.getAllWithLiquidityInfo( | ||
presentInvalidTokens, | ||
onlyListed, | ||
); | ||
} | ||
|
||
async getCountStats() { | ||
return { | ||
all: await dal.pair.count(presentInvalidTokens), | ||
synced: await dal.pair.count(presentInvalidTokens, 'synchronized'), | ||
listed: await dal.pair.count(presentInvalidTokens, 'listed'), | ||
all: await this.pairDbService.count(presentInvalidTokens), | ||
synced: await this.pairDbService.count( | ||
presentInvalidTokens, | ||
'synchronized', | ||
), | ||
listed: await this.pairDbService.count(presentInvalidTokens, 'listed'), | ||
}; | ||
} | ||
|
||
async getPair(address: string) { | ||
return dal.pair.getOne(address); | ||
return this.pairDbService.getOne(address); | ||
} | ||
|
||
async getTopHeight() { | ||
return dal.pair.getTopHeight(); | ||
return this.pairDbService.getTopHeight(); | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
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
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
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 |
---|---|---|
@@ -1,20 +1,23 @@ | ||
import { Module } from '@nestjs/common'; | ||
import { PrismaService } from './prisma.service'; | ||
import { PairDbService } from './pair-db.service'; | ||
import { PairLiquidityInfoHistoryDbService } from './pair-liquidity-info-history-db.service'; | ||
import { PairLiquidityInfoHistoryErrorDbService } from './pair-liquidity-info-history-error-db.service'; | ||
import { PairDbService } from './pair/pair-db.service'; | ||
import { PairLiquidityInfoHistoryDbService } from './pair-liquidity-info-history/pair-liquidity-info-history-db.service'; | ||
import { PairLiquidityInfoHistoryErrorDbService } from './pair-liquidity-info-history-error/pair-liquidity-info-history-error-db.service'; | ||
import { TokenDbService } from './token/token-db.service'; | ||
|
||
@Module({ | ||
providers: [ | ||
PrismaService, | ||
PairDbService, | ||
PairLiquidityInfoHistoryDbService, | ||
PairLiquidityInfoHistoryErrorDbService, | ||
TokenDbService, | ||
], | ||
exports: [ | ||
PairDbService, | ||
PairLiquidityInfoHistoryDbService, | ||
PairLiquidityInfoHistoryErrorDbService, | ||
TokenDbService, | ||
], | ||
}) | ||
export class DatabaseModule {} |
This file was deleted.
Oops, something went wrong.
2 changes: 1 addition & 1 deletion
2
...info-history-error-db.service.e2e-spec.ts → ...info-history-error-db.service.e2e-spec.ts
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
2 changes: 1 addition & 1 deletion
2
...iquidity-info-history-error-db.service.ts → ...iquidity-info-history-error-db.service.ts
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
6 changes: 3 additions & 3 deletions
6
...idity-info-history-db.service.e2e-spec.ts → ...idity-info-history-db.service.e2e-spec.ts
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
6 changes: 3 additions & 3 deletions
6
...pair-liquidity-info-history-db.service.ts → ...pair-liquidity-info-history-db.service.ts
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
Oops, something went wrong.