Skip to content

Commit

Permalink
update redis config
Browse files Browse the repository at this point in the history
  • Loading branch information
harisato committed Feb 22, 2024
1 parent 6d909f6 commit add8a9f
Show file tree
Hide file tree
Showing 5 changed files with 52 additions and 53 deletions.
31 changes: 20 additions & 11 deletions src/app.module.ts
Original file line number Diff line number Diff line change
@@ -1,21 +1,24 @@
import { CacheModule, Module } from '@nestjs/common';
import { HttpModule } from '@nestjs/axios';
import { TypeOrmModule } from '@nestjs/typeorm';
import { ScheduleModule } from '@nestjs/schedule';
import { ConfigModule, ConfigService } from '@nestjs/config';
import { BullModule } from '@nestjs/bull';
import { SharedModule } from './shared/shared.module';
import { SeederModule } from './modules/seeders/seeder.module';
import { CacheModule, Module } from '@nestjs/common';
import { ConfigModule, ConfigService } from '@nestjs/config';
import { ScheduleModule } from '@nestjs/schedule';
import { TypeOrmModule } from '@nestjs/typeorm';

import { AuthModule } from './modules/auth/auth.module';
import { SafeModule } from './modules/safe/safe.module';
import { JwtStrategy } from './modules/auth/jwt.strategy';
import { ChainModule } from './modules/chain/chain.module';
import { MultisigTransactionModule } from './modules/multisig-transaction/multisig-transaction.module';
import { NotifyProposalModule } from './modules/jobs/notify-proposal.module';
import {
MultisigTransactionModule
} from './modules/multisig-transaction/multisig-transaction.module';
import { NotificationModule } from './modules/notification/notification.module';
import { SafeOwnerModule } from './modules/safe-owner/safe-owner.module';
import { SafeModule } from './modules/safe/safe.module';
import { SeederModule } from './modules/seeders/seeder.module';
import { UserModule } from './modules/user/user.module';
import { JwtStrategy } from './modules/auth/jwt.strategy';
import { NotifyProposalModule } from './modules/jobs/notify-proposal.module';
import { CustomConfigService } from './shared/services/custom-config.service';
import { SharedModule } from './shared/shared.module';

@Module({
imports: [
Expand All @@ -39,6 +42,11 @@ import { CustomConfigService } from './shared/services/custom-config.service';
port: configService.get('REDIS_PORT'),
db: configService.get('REDIS_DB'),
},
prefix: 'multisig',
defaultJobOptions: {
removeOnComplete: true,
removeOnFail: true
}
}),
inject: [ConfigService],
}),
Expand All @@ -58,7 +66,8 @@ import { CustomConfigService } from './shared/services/custom-config.service';
SafeOwnerModule,
UserModule,
NotifyProposalModule,
SeederModule
],
providers: [JwtStrategy],
})
export class AppModule {}
export class AppModule { }
22 changes: 6 additions & 16 deletions src/main.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import { Logger, ValidationPipe } from '@nestjs/common';
import bodyParser from 'body-parser';
import { middleware as expressCtx } from 'express-ctx';
import * as swaggerStats from 'swagger-stats';

import { ValidationPipe } from '@nestjs/common';
import { ConfigService } from '@nestjs/config';
import { NestFactory } from '@nestjs/core';
import { DocumentBuilder, SwaggerModule } from '@nestjs/swagger';
import { middleware as expressCtx } from 'express-ctx';
import bodyParser from 'body-parser';
import * as swaggerStats from 'swagger-stats';

import { AppModule } from './app.module';
import { SeederModule } from './modules/seeders/seeder.module';
import { SeederService } from './modules/seeders/seeder.service';
import { SharedModule } from './shared/shared.module';

// eslint-disable-next-line no-void
Expand All @@ -29,16 +29,6 @@ void (async function bootstrap() {

const configService = app.select(SharedModule).get(ConfigService);

// create or update chain info
const seederService = app.select(SeederModule).get(SeederService);
try {
await seederService.seed();
Logger.debug('Seed completed');
} catch (error) {
Logger.error(error);
await app.close();
}

// setup swagger
const config = new DocumentBuilder()
.setTitle('Multisig Wallet API for Aura Network')
Expand Down
21 changes: 11 additions & 10 deletions src/modules/multisig-transaction/multisig-transaction.module.ts
Original file line number Diff line number Diff line change
@@ -1,20 +1,21 @@
import { BullModule } from '@nestjs/bull';
import { Module } from '@nestjs/common';
import { TypeOrmModule } from '@nestjs/typeorm';
import { BullModule } from '@nestjs/bull';
import { MultisigTransactionService } from './multisig-transaction.service';
import { MultisigTransactionController } from './multisig-transaction.controller';
import { MultisigTransactionRepository } from './multisig-transaction.repository';
import { MultisigTransaction } from './entities/multisig-transaction.entity';

import { AuraTxModule } from '../aura-tx/aura-tx.module';
import { MultisigConfirmModule } from '../multisig-confirm/multisig-confirm.module';
import { ChainModule } from '../chain/chain.module';
import { SafeModule } from '../safe/safe.module';
import { SafeOwnerModule } from '../safe-owner/safe-owner.module';
import { MessageModule } from '../message/message.module';
import { MultisigConfirmModule } from '../multisig-confirm/multisig-confirm.module';
import { NotificationModule } from '../notification/notification.module';
import { TransactionHistoryModule } from '../transaction-history/transaction-history.module';
import { SafeOwnerModule } from '../safe-owner/safe-owner.module';
import { SafeModule } from '../safe/safe.module';
import { SimulateModule } from '../simulate/simulate.module';
import { TransactionHistoryModule } from '../transaction-history/transaction-history.module';
import { MultisigTransaction } from './entities/multisig-transaction.entity';
import { MultisigTransactionController } from './multisig-transaction.controller';
import { MultisigTxProcessor } from './multisig-transaction.processor';
import { MultisigTransactionRepository } from './multisig-transaction.repository';
import { MultisigTransactionService } from './multisig-transaction.service';

@Module({
imports: [
Expand All @@ -40,4 +41,4 @@ import { MultisigTxProcessor } from './multisig-transaction.processor';
],
exports: [MultisigTransactionRepository],
})
export class MultisigTransactionModule {}
export class MultisigTransactionModule { }
12 changes: 7 additions & 5 deletions src/modules/seeders/seeder.service.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,18 @@
import { Injectable } from '@nestjs/common';
import { validate } from 'class-validator';
import { ChainRepository } from '../chain/chain.repository';

import { Injectable, OnModuleInit } from '@nestjs/common';

import { CommonService } from '../../shared/services';
import { ChainRepository } from '../chain/chain.repository';

@Injectable()
export class SeederService {
export class SeederService implements OnModuleInit {
constructor(
private chainRepo: ChainRepository,
private commonSvc: CommonService,
) {}
) { }

async seed() {
async onModuleInit() {
await this.seedChain();
}

Expand Down
19 changes: 8 additions & 11 deletions src/shared/services/indexer-v2.service.ts
Original file line number Diff line number Diff line change
@@ -1,28 +1,24 @@
import { Injectable, Logger } from '@nestjs/common';
import { isNumber } from 'lodash';

import { Injectable, Logger } from '@nestjs/common';

import { CustomError } from '../../common/custom-error';
import { ErrorMap } from '../../common/error.map';
import {
IAccountInfo,
IAccounts,
IContractAddress,
IIndexerV2Response,
IProposal,
IProposals,
IPubkey,
IAccountInfo, IAccounts, IContractAddress, IIndexerV2Response, IProposal, IProposals, IPubkey
} from '../../interfaces';
import { IndexerResponseDto } from '../dtos';
import { CommonService } from './common.service';
import { IAssetsWithType } from '../../interfaces/asset-by-owner.interface';
import { ChainInfo } from '../../utils/validations';
import { IndexerResponseDto } from '../dtos';
import { CommonService } from './common.service';

@Injectable()
export class IndexerV2Client {
private readonly logger = new Logger(IndexerV2Client.name);

chainInfos: ChainInfo[];

constructor(private commonService: CommonService) {}
constructor(private commonService: CommonService) { }

async getCw20Contract(contractAddress: string, chainId: string) {
const chainInfos = await this.commonService.readConfigurationFile();
Expand Down Expand Up @@ -205,6 +201,7 @@ export class IndexerV2Client {
): Promise<IProposal[]> {
const chainInfos = await this.commonService.readConfigurationFile();
const selectedChain = chainInfos.find((e) => e.chainId === chainId);
if (!selectedChain) return [];
const operationName = 'proposal';
const operatorDocs = `
query ${operationName}($limit: Int = 10, $order: order_by = desc, $proposalId: Int = null) {
Expand Down

0 comments on commit add8a9f

Please sign in to comment.