Skip to content

Commit

Permalink
Merge pull request #21 from near-daos/develop
Browse files Browse the repository at this point in the history
fixed deployment configuration for exchange related services
  • Loading branch information
okalenyk authored Jan 19, 2022
2 parents f17d4be + dd93525 commit 930dcdb
Show file tree
Hide file tree
Showing 38 changed files with 142 additions and 90 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,5 @@ data:
NEST_APP_TYPE: aggregator
AGGREGATOR_POLLING_SCHEDULE: "{{ .Values.environment.aggregator_polling_schedule }}"
LOG_LEVELS: "log,warn,error"
SODAKI_API_BASE_URL: "{{ .Values.environment.sodaki_api_base_url }}"
COINGECKO_API_BASE_URL: "{{ .Values.environment.coingecko_api_base_url }}"
2 changes: 2 additions & 0 deletions apps/aggregator/deployment/app-chart/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -87,3 +87,5 @@ version:

environment:
aggregator_polling_schedule: "0 * * * *"
sodaki_api_base_url: "https://sodaki.com/api"
coingecko_api_base_url: "https://api.coingecko.com/api/v3"
10 changes: 5 additions & 5 deletions apps/aggregator/src/aggregator.module.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { ClassSerializerInterceptor, Module } from '@nestjs/common';
import { APP_INTERCEPTOR } from '@nestjs/core';
import { ConfigModule } from '@nestjs/config';
import { TypeOrmModule } from '@nestjs/typeorm';
import { ScheduleModule } from '@nestjs/schedule';
Expand All @@ -13,16 +14,15 @@ import { RedisModule } from '@dao-stats/redis';
import { TransactionModule } from '@dao-stats/transaction';
import { HttpCacheModule } from '@dao-stats/cache';
import {
CoinPriceHistoryModule,
ContractModule,
DaoStatsModule,
DaoStatsHistoryModule,
DaoModule,
} from '@dao-stats/common';
import { AggregatorService } from './aggregator.service';
import { APP_INTERCEPTOR } from '@nestjs/core';
import { ReceiptModule } from '@dao-stats/receipt';
import { CoinPriceHistoryModule } from '@dao-stats/common/coin-price-history.module';
import { ContractModule } from 'apps/api/src/contract/contract.module';
import { ExchangeModule } from 'libs/exchange/src/exchange.module';
import { ExchangeModule } from '@dao-stats/exchange';
import { AggregatorService } from './aggregator.service';

@Module({
imports: [
Expand Down
14 changes: 7 additions & 7 deletions apps/aggregator/src/aggregator.service.ts
Original file line number Diff line number Diff line change
@@ -1,25 +1,25 @@
import moment from 'moment';
import { CronJob } from 'cron';
import { ConfigService } from '@nestjs/config';
import { LazyModuleLoader } from '@nestjs/core';
import { Injectable, Logger } from '@nestjs/common';
import { SchedulerRegistry } from '@nestjs/schedule';
import { CronJob } from 'cron';
import {
Aggregator,
AGGREGATOR_POLLING_CRON_JOB,
CoinPriceHistoryService,
ContractService,
CurrencyType,
DaoService,
DaoStatsService,
DaoStatsHistoryService,
DaoStatsService,
millisToNanos,
nanosToMillis,
AGGREGATOR_POLLING_CRON_JOB,
} from '@dao-stats/common';
import { TransactionService } from '@dao-stats/transaction';
import { CacheService } from '@dao-stats/cache';
import { ReceiptActionService } from '@dao-stats/receipt';
import { ContractService } from 'apps/api/src/contract/contract.service';
import { CurrencyType } from '@dao-stats/common/types/currency-type';
import { CoinGeckoService, SodakiService } from '@dao-stats/exchange';
import { CoinPriceHistoryService } from '@dao-stats/common/coin-price-history.service';

@Injectable()
export class AggregatorService {
Expand Down Expand Up @@ -165,7 +165,7 @@ export class AggregatorService {
);
}

this.coinPriceHistoryService.createOrUpdate({
await this.coinPriceHistoryService.createOrUpdate({
coin,
currency: CurrencyType[currency],
price,
Expand Down
8 changes: 6 additions & 2 deletions apps/api/src/api.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@ import { ApiValidationSchema } from '@dao-stats/config/validation/api.schema';
import { HttpCacheModule } from '@dao-stats/cache';
import {
Contract,
ContractModule,
DaoContractContext,
DaoModule,
Receipt,
ReceiptAction,
Transaction,
Expand All @@ -31,7 +33,7 @@ import {
DaoContractContextInterceptor,
HttpCacheInterceptor,
} from './interceptors';
import { ContractModule } from './contract/contract.module';
import { ApiContractModule } from './contract/contract.module';
import { GeneralModule } from './general/general.module';
import { UsersModule } from './users/users.module';
import { GovernanceModule } from './governance/governance.module';
Expand Down Expand Up @@ -60,9 +62,11 @@ import { MarketModule } from './market/market.module';
useClass: TypeOrmConfigService,
}),
TypeOrmModule.forFeature([Contract, Receipt, ReceiptAction, Transaction]),
ContractModule,
DaoModule,
HttpCacheModule,
RedisModule,
ContractModule,
ApiContractModule,
ApiDaoModule,
GeneralModule,
UsersModule,
Expand Down
7 changes: 3 additions & 4 deletions apps/api/src/contract/contract.controller.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { Controller, Get } from '@nestjs/common';
import { ApiBadRequestResponse, ApiResponse, ApiTags } from '@nestjs/swagger';
import { ContractResponse } from './dto';
import { ContractService } from './contract.service';
import { ContractDto, ContractService } from '@dao-stats/common';
import { NoContractContext } from '../decorators';

@ApiTags('Contracts')
Expand All @@ -11,14 +10,14 @@ export class ContractController {

@ApiResponse({
status: 200,
type: [ContractResponse],
type: [ContractDto],
})
@ApiBadRequestResponse({
description: 'Bad Request Response based on the query params set',
})
@NoContractContext()
@Get()
async contracts(): Promise<ContractResponse[]> {
async contracts(): Promise<ContractDto[]> {
return this.contractService.find();
}
}
10 changes: 3 additions & 7 deletions apps/api/src/contract/contract.module.ts
Original file line number Diff line number Diff line change
@@ -1,21 +1,17 @@
import { TypeOrmModule } from '@nestjs/typeorm';
import { CacheModule, Module } from '@nestjs/common';

import { CacheConfigService } from '@dao-stats/config/cache';
import { Contract } from '@dao-stats/common';
import { ContractModule } from '@dao-stats/common';

import { ContractController } from './contract.controller';
import { ContractService } from './contract.service';

@Module({
imports: [
CacheModule.registerAsync({
useClass: CacheConfigService,
}),
TypeOrmModule.forFeature([Contract]),
ContractModule,
],
providers: [ContractService],
controllers: [ContractController],
exports: [ContractService],
})
export class ContractModule {}
export class ApiContractModule {}
1 change: 0 additions & 1 deletion apps/api/src/contract/dto/index.ts

This file was deleted.

8 changes: 2 additions & 6 deletions apps/api/src/dao/dao.module.ts
Original file line number Diff line number Diff line change
@@ -1,22 +1,18 @@
import { TypeOrmModule } from '@nestjs/typeorm';
import { CacheModule, Module } from '@nestjs/common';

import { CacheConfigService } from '@dao-stats/config/cache';
import { Dao, DaoService } from '@dao-stats/common';
import { ContractModule, DaoModule } from '@dao-stats/common';

import { DaoController } from './dao.controller';
import { ContractModule } from '../contract/contract.module';

@Module({
imports: [
CacheModule.registerAsync({
useClass: CacheConfigService,
}),
TypeOrmModule.forFeature([Dao]),
ContractModule,
DaoModule,
],
providers: [DaoService],
controllers: [DaoController],
exports: [DaoService],
})
export class ApiDaoModule {}
7 changes: 5 additions & 2 deletions apps/api/src/general/general.module.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
import { CacheModule, Module } from '@nestjs/common';

import { CacheConfigService } from '@dao-stats/config/cache';
import { DaoStatsModule, DaoStatsHistoryModule } from '@dao-stats/common';
import {
ContractModule,
DaoStatsModule,
DaoStatsHistoryModule,
} from '@dao-stats/common';
import { TransactionModule } from '@dao-stats/transaction';
import { GeneralController } from './general.controller';
import { GeneralService } from './general.service';
import { ContractModule } from '../contract/contract.module';
import { MetricService } from '../common/metric.service';

@Module({
Expand Down
7 changes: 5 additions & 2 deletions apps/api/src/governance/governance.module.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
import { CacheModule, Module } from '@nestjs/common';

import { CacheConfigService } from '@dao-stats/config/cache';
import { DaoStatsModule, DaoStatsHistoryModule } from '@dao-stats/common';
import {
ContractModule,
DaoStatsModule,
DaoStatsHistoryModule,
} from '@dao-stats/common';
import { TransactionModule } from '@dao-stats/transaction';

import { GovernanceController } from './governance.controller';
import { GovernanceService } from './governance.service';
import { ContractModule } from '../contract/contract.module';
import { MetricService } from '../common/metric.service';

@Module({
Expand Down
10 changes: 6 additions & 4 deletions apps/api/src/governance/governance.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,12 @@ import {
TransactionType,
} from '@dao-stats/common';
import { TransactionService } from '@dao-stats/transaction';
import { GovernanceTotalResponse } from './dto/governance-total.dto';
import { ProposalsTypesLeaderboardResponse } from './dto/proposals-types-leaderboard-response.dto';
import { ProposalsTypesHistoryResponse } from './dto/proposals-types-history-response.dto';
import { VoteRateLeaderboardResponse } from './dto/vote-rate-leaderboard-response.dto';
import {
GovernanceTotalResponse,
ProposalsTypesHistoryResponse,
ProposalsTypesLeaderboardResponse,
VoteRateLeaderboardResponse,
} from './dto';
import { MetricService } from '../common/metric.service';
import { getGrowth, getRate, patchMetricDays } from '../utils';

Expand Down
7 changes: 5 additions & 2 deletions apps/api/src/interceptors/contract-context.interceptor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,11 @@ import {
} from '@nestjs/common';
import { RequestContext } from '@medibloc/nestjs-request-context';

import { ContractContext, NO_CONTRACT_CONTEXT } from '@dao-stats/common';
import { ContractService } from '../contract/contract.service';
import {
ContractContext,
ContractService,
NO_CONTRACT_CONTEXT,
} from '@dao-stats/common';

@Injectable()
export class ContractContextInterceptor implements NestInterceptor {
Expand Down
2 changes: 1 addition & 1 deletion apps/api/src/market/dto/coin-price-history.dto.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { ApiProperty } from '@nestjs/swagger';

import { CoinType, CurrencyType } from '@dao-stats/common/types';
import { CoinType, CurrencyType } from '@dao-stats/common';

export class CoinPriceHistoryResponse {
@ApiProperty()
Expand Down
3 changes: 1 addition & 2 deletions apps/api/src/market/market.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@ import {
ApiTags,
} from '@nestjs/swagger';

import { CoinType } from '@dao-stats/common/types';
import { CoinPriceQuery } from '@dao-stats/common/dto';
import { CoinType, CoinPriceQuery } from '@dao-stats/common';

import { MarketService } from './market.service';
import { NoContractContext } from '../decorators';
Expand Down
8 changes: 5 additions & 3 deletions apps/api/src/market/market.service.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
import { Injectable } from '@nestjs/common';
import moment from 'moment';

import { CoinPriceHistoryService } from '@dao-stats/common';
import { CoinPriceQuery } from '@dao-stats/common/dto';
import { CoinType } from '@dao-stats/common/types';
import {
CoinPriceHistoryService,
CoinPriceQuery,
CoinType,
} from '@dao-stats/common';

import { CoinPriceHistoryResponse } from './dto';

Expand Down
7 changes: 5 additions & 2 deletions apps/api/src/tokens/tokens.module.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
import { CacheModule, Module } from '@nestjs/common';

import { CacheConfigService } from '@dao-stats/config/cache';
import { DaoStatsHistoryModule, DaoStatsModule } from '@dao-stats/common';
import {
ContractModule,
DaoStatsHistoryModule,
DaoStatsModule,
} from '@dao-stats/common';
import { TransactionModule } from '@dao-stats/transaction';

import { TokensController } from './tokens.controller';
import { TokensService } from './tokens.service';
import { ContractModule } from '../contract/contract.module';
import { MetricService } from '../common/metric.service';

@Module({
Expand Down
4 changes: 2 additions & 2 deletions apps/api/src/tvl/tvl.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@ import { CacheModule, Module } from '@nestjs/common';

import { CacheConfigService } from '@dao-stats/config/cache';
import {
CoinPriceHistoryModule,
ContractModule,
DaoStatsHistoryModule,
DaoStatsModule,
CoinPriceHistoryModule,
} from '@dao-stats/common';
import { TransactionModule } from '@dao-stats/transaction';

import { TvlController } from './tvl.controller';
import { TvlService } from './tvl.service';
import { ContractModule } from '../contract/contract.module';
import { MetricService } from '../common/metric.service';

@Module({
Expand Down
7 changes: 5 additions & 2 deletions apps/api/src/users/users.module.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
import { CacheModule, Module } from '@nestjs/common';

import { CacheConfigService } from '@dao-stats/config/cache';
import { DaoStatsHistoryModule, DaoStatsModule } from '@dao-stats/common';
import {
ContractModule,
DaoStatsHistoryModule,
DaoStatsModule,
} from '@dao-stats/common';
import { TransactionModule } from '@dao-stats/transaction';

import { UsersController } from './users.controller';
import { UsersService } from './users.service';
import { ContractModule } from '../contract/contract.module';
import { MetricService } from '../common/metric.service';

@Module({
Expand Down
3 changes: 2 additions & 1 deletion libs/astro/src/astro.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,12 @@ import { NearModule } from '@dao-stats/near';

import { AstroService } from './astro.service';
import configuration from './config/configuration';
import exchange from '@dao-stats/config/exchange-config';

@Module({
imports: [
ConfigModule.forRoot({
load: [configuration],
load: [configuration, exchange],
}),
NearModule,
],
Expand Down
5 changes: 2 additions & 3 deletions libs/common/src/coin-price-history.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,8 @@ import { Connection, InsertResult, Repository } from 'typeorm';
import { Injectable } from '@nestjs/common';
import { InjectConnection, InjectRepository } from '@nestjs/typeorm';

import { CoinPriceHistory } from './entities/coin-price-history.entity';
import { CoinType } from './types/coin-type';
import { CurrencyType } from './types/currency-type';
import { CoinPriceHistory } from './entities';
import { CoinType, CurrencyType } from './types';

@Injectable()
export class CoinPriceHistoryService {
Expand Down
12 changes: 12 additions & 0 deletions libs/common/src/contract.module.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { TypeOrmModule } from '@nestjs/typeorm';
import { Module } from '@nestjs/common';

import { Contract } from './entities';
import { ContractService } from './contract.service';

@Module({
imports: [TypeOrmModule.forFeature([Contract])],
providers: [ContractService],
exports: [ContractService],
})
export class ContractModule {}
Loading

0 comments on commit 930dcdb

Please sign in to comment.