Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
RiXelanya committed Feb 20, 2024
1 parent 7c7e5a4 commit 137797f
Show file tree
Hide file tree
Showing 56 changed files with 74 additions and 769 deletions.
9 changes: 2 additions & 7 deletions src/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import { EscrowAccounts } from '@common/escrow/models/deposit.entity';
import { IndexerModule } from '@indexer/indexer.module';
import { SubstrateListenerModule } from '@listeners/substrate-listener/substrate-listener.module';
import { SchedulersModule } from '@schedulers/schedulers.module';
import { keyList, SecretKeyList } from '@common/secrets';
import { config } from './config';

// eslint-disable-next-line @typescript-eslint/no-var-requires
Expand All @@ -29,9 +28,7 @@ require('dotenv').config();
}),
],
inject: [ProcessEnvProxy],
useFactory: async (
processEnvProxy: ProcessEnvProxy,
) => {
useFactory: async (processEnvProxy: ProcessEnvProxy) => {
return {
type: 'postgres',
host: processEnvProxy.env.HOST_POSTGRES,
Expand All @@ -54,9 +51,7 @@ require('dotenv').config();
}),
],
inject: [ProcessEnvProxy],
useFactory: async (
processEnvProxy: ProcessEnvProxy,
) => {
useFactory: async (processEnvProxy: ProcessEnvProxy) => {
return {
type: 'postgres',
host: processEnvProxy.env.HOST_POSTGRES,
Expand Down
5 changes: 2 additions & 3 deletions src/common/caches/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { CacheModule, Module } from '@nestjs/common';
import { CachesService } from './caches.service';
import * as redisStore from 'cache-manager-redis-store';
import { config } from 'src/config';
import { config } from '../../config';

require('dotenv').config(); // eslint-disable-line

Expand All @@ -10,8 +10,7 @@ require('dotenv').config(); // eslint-disable-line
CacheModule.registerAsync({
imports: [],
inject: [],
useFactory: async (
) => {
useFactory: async () => {
return {
store: redisStore,
host: config.REDIS_HOST.toString(),
Expand Down
3 changes: 1 addition & 2 deletions src/common/common.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@ require('dotenv').config();
ElasticsearchModule.registerAsync({
imports: [],
inject: [],
useFactory: async (
) => ({
useFactory: async () => ({
node: config.ELASTICSEARCH_NODE.toString(),
auth: {
username: config.ELASTICSEARCH_USERNAME.toString(),
Expand Down
3 changes: 1 addition & 2 deletions src/common/debio-conversion/debio-conversion.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@ import { Module } from '@nestjs/common';
import { DebioConversionService } from './debio-conversion.service';

@Module({
imports: [
],
imports: [],
providers: [DebioConversionService],
exports: [DebioConversionService],
})
Expand Down
4 changes: 1 addition & 3 deletions src/common/debio-conversion/debio-conversion.service.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
import { Injectable, Logger } from '@nestjs/common';
import axios from 'axios';
import { config } from 'src/config';
import { config } from '../../config';

@Injectable()
export class DebioConversionService {
private readonly logger: Logger = new Logger(DebioConversionService.name);
constructor(
) {}

async getExchange() {
try {
Expand Down
3 changes: 1 addition & 2 deletions src/common/ethereum/ethereum.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,7 @@ import { config } from '../../config';
}),
],
inject: [],
useFactory: async (
) => {
useFactory: async () => {
return {
network: config.WEB3_RPC_HTTPS.toString(),
useDefaultProvider: true,
Expand Down
14 changes: 3 additions & 11 deletions src/common/mailer/mailer.manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,7 @@ import { config } from '../../config';
@Injectable()
export class MailerManager {
private readonly _logger: Logger = new Logger(MailerManager.name);
constructor(
private readonly mailerService: MailerService,
) {}
constructor(private readonly mailerService: MailerService) {}

async sendNewOrderToLab(to: string, context: NewOrderLab) {
const subject = `New Order #1`;
Expand All @@ -37,10 +35,7 @@ export class MailerManager {
context: CustomerStakingRequestService,
) {
let subject = `New Service Request - ${context.service_name} - ${context.city}, ${context.state}, ${context.country}`;
if (
config.POSTGRES_HOST.toString() ===
'localhost'
) {
if (config.POSTGRES_HOST.toString() === 'localhost') {
subject = `Testing New Service Request Email`;
}
this.mailerService.sendMail({
Expand All @@ -53,10 +48,7 @@ export class MailerManager {

async sendLabRegistrationEmail(to: string | string[], context: LabRegister) {
let subject = `New Lab Register – ${context.lab_name} - ${context.city}, ${context.state}, ${context.country}`;
if (
config.POSTGRES_HOST.toString() ===
'localhost'
) {
if (config.POSTGRES_HOST.toString() === 'localhost') {
subject = `Testing New Lab Register Email`;
}
const files: any[] = [];
Expand Down
6 changes: 2 additions & 4 deletions src/common/mailer/mailer.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,9 @@ import { config } from '../../config';
@Module({
imports: [
MailerModule.forRootAsync({
imports: [
],
imports: [],
inject: [],
useFactory: async (
) => {
useFactory: async () => {
return {
transport: {
host: 'smtp.gmail.com',
Expand Down
3 changes: 1 addition & 2 deletions src/common/substrate/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@ import { Module } from '@nestjs/common';
import { SubstrateService } from './substrate.service';

@Module({
imports: [
],
imports: [],
providers: [SubstrateService],
exports: [SubstrateService],
})
Expand Down
7 changes: 1 addition & 6 deletions src/common/substrate/substrate.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,6 @@ export class SubstrateService implements OnModuleInit {
private _listenStatus: boolean;
private readonly _logger: Logger = new Logger(SubstrateService.name);

constructor(
) {}

get api(): ApiPromise {
return this._api;
}
Expand All @@ -23,9 +20,7 @@ export class SubstrateService implements OnModuleInit {
}

async onModuleInit() {
this._wsProvider = new WsProvider(
config.SUBSTRATE_URL.toString(),
);
this._wsProvider = new WsProvider(config.SUBSTRATE_URL.toString());

const keyring = new Keyring({ type: 'sr25519' });
await waitReady();
Expand Down
11 changes: 6 additions & 5 deletions src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,10 @@ export const config = {
MYRIAD_MENTAL_HEALTH_TIMELINE_ID:
process.env.MENTAL_HEALTH_EXPERIENCE_ID ?? '',
PINATA_JWT: process.env.PINATA_SECRET_KEY ?? '',
GA_ORDER_LINK : process.env.GA_ORDER_LINK ?? '',
LAB_ORDER_LINK : process.env.LAB_ORDER_LINK ?? '',
UNSTAKE_INTERVAL : process.env.UNSTAKE_INTERVAL ?? '',
UNSTAKE_TIMER : process.env.UNSTAKE_TIMER ?? '',
MENSTRUAL_SUBSCRIPTION_DURATION : process.env.MENSTRUAL_SUBSCRIPTION_DURATION ?? '',
GA_ORDER_LINK: process.env.GA_ORDER_LINK ?? '',
LAB_ORDER_LINK: process.env.LAB_ORDER_LINK ?? '',
UNSTAKE_INTERVAL: process.env.UNSTAKE_INTERVAL ?? '',
UNSTAKE_TIMER: process.env.UNSTAKE_TIMER ?? '',
MENSTRUAL_SUBSCRIPTION_DURATION:
process.env.MENSTRUAL_SUBSCRIPTION_DURATION ?? '',
};
4 changes: 1 addition & 3 deletions src/indexer/indexer.handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,7 @@ export class IndexerHandler
delete this.wsProvider;
}

this.wsProvider = new WsProvider(
config.SUBSTRATE_URL.toString(),
);
this.wsProvider = new WsProvider(config.SUBSTRATE_URL.toString());

this.wsProvider.on('connected', () => {
this.logger.log(`WS Connected`);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ export class GeneticAnalysisOrderPaidHandler
);

const linkOrder =
config.GA_ORDER_LINK ?.toString() ?? '' + geneticAnalysisOrder.id;
config.GA_ORDER_LINK?.toString() ?? '' + geneticAnalysisOrder.id;

await this.mailerManager.sendNewOrderToGa(
geneticAnaystDetail.info.email,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,7 @@ export class OrderPaidHandler implements ICommandHandler<OrderPaidCommand> {
order.serviceId,
);

const linkOrder =
config.LAB_ORDER_LINK.toString() ?? '' + order.id;
const linkOrder = config.LAB_ORDER_LINK.toString() ?? '' + order.id;

await this.mailerManager.sendNewOrderToLab(labDetail.info.email, {
specimen_number: order.dnaSampleTrackingId,
Expand Down
12 changes: 4 additions & 8 deletions src/listeners/substrate-listener/substrate-listener.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,9 @@ import { config } from '../../config';
DateTimeModule,
NotificationModule,
ElasticsearchModule.registerAsync({
imports: [
],
imports: [],
inject: [],
useFactory: async (
) => {
useFactory: async () => {
return {
node: config.ELASTICSEARCH_NODE.toString(),
auth: {
Expand All @@ -57,11 +55,9 @@ import { config } from '../../config';
},
}),
MailerModule.forRootAsync({
imports: [
],
imports: [],
inject: [],
useFactory: async (
) => {
useFactory: async () => {
return {
transport: {
host: 'smtp.gmail.com',
Expand Down
4 changes: 1 addition & 3 deletions src/schedulers/genetic-analyst-unstaked/unstaked.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,7 @@ export class GeneticAnalystUnstakedService implements OnModuleInit {
) {}

onModuleInit() {
this.timer = strToMilisecond(
config.UNSTAKE_TIMER.toString(),
);
this.timer = strToMilisecond(config.UNSTAKE_TIMER.toString());
const unstakeInterval: number = strToMilisecond(
config.UNSTAKE_INTERVAL.toString(),
);
Expand Down
4 changes: 1 addition & 3 deletions src/schedulers/lab-unstake/lab-unstake.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,7 @@ export class LabUnstakedService implements OnModuleInit {
) {}

onModuleInit() {
this.timer = strToMilisecond(
config.UNSTAKE_TIMER.toString(),
);
this.timer = strToMilisecond(config.UNSTAKE_TIMER.toString());
const unstakeInterval: number = strToMilisecond(
config.UNSTAKE_INTERVAL.toString(),
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -235,9 +235,7 @@ export class MenstrualSubscriptionService {
parseMenstrualSubscriptionDuration(): { [key: string]: number } {
try {
const menstrualSubscriptionDurationObj: { [key: string]: string } =
JSON.parse(
config.MENSTRUAL_SUBSCRIPTION_DURATION.toString() ?? '{}',
);
JSON.parse(config.MENSTRUAL_SUBSCRIPTION_DURATION.toString() ?? '{}');
const parseMenstrualSubscriptionDuration: Map<string, number> = new Map<
string,
number
Expand Down
6 changes: 2 additions & 4 deletions src/schedulers/schedulers.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,9 @@ import { config } from '../config';
@Module({
imports: [
ElasticsearchModule.registerAsync({
imports: [
],
imports: [],
inject: [],
useFactory: async (
) => {
useFactory: async () => {
return {
node: config.ELASTICSEARCH_NODE.toString(),
auth: {
Expand Down
4 changes: 1 addition & 3 deletions src/schedulers/unstaked/unstaked.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,7 @@ export class UnstakedService implements OnModuleInit {
) {}

onModuleInit() {
this.timer = strToMilisecond(
config.UNSTAKE_TIMER.toString(),
);
this.timer = strToMilisecond(config.UNSTAKE_TIMER.toString());
const unstakeInterval: number = strToMilisecond(
config.UNSTAKE_INTERVAL.toString(),
);
Expand Down
23 changes: 1 addition & 22 deletions test/e2e/indexer/events/certification-events.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,26 +42,6 @@ describe('Certification Event', () => {
error: jest.fn(),
};

class GoogleSecretManagerServiceMock {
_secretsList = new Map<string, string>([
['ELASTICSEARCH_NODE', process.env.ELASTICSEARCH_NODE],
['ELASTICSEARCH_USERNAME', process.env.ELASTICSEARCH_USERNAME],
['ELASTICSEARCH_PASSWORD', process.env.ELASTICSEARCH_PASSWORD],
['SUBSTRATE_URL', process.env.SUBSTRATE_URL],
['ADMIN_SUBSTRATE_MNEMONIC', process.env.ADMIN_SUBSTRATE_MNEMONIC],
['EMAIL', process.env.EMAIL],
['PASS_EMAIL', process.env.PASS_EMAIL],
]);

loadSecrets() {
return null;
}

getSecret(key) {
return this._secretsList.get(key);
}
}

beforeAll(async () => {
const module: TestingModule = await Test.createTestingModule({
imports: [
Expand All @@ -76,8 +56,7 @@ describe('Certification Event', () => {
...LabCommandHandlers,
...CertificationsCommandHandlers,
],
})
.compile();
}).compile();

elasticsearchService =
module.get<ElasticsearchService>(ElasticsearchService);
Expand Down
24 changes: 1 addition & 23 deletions test/e2e/indexer/events/genetic-analysis-events.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ import { CommonModule, ProcessEnvModule } from '@common/index';
import { IndexerHandler } from '@indexer/indexer.handler';
import { IndexerModule } from '@indexer/indexer.module';
import { geneticAnalystServiceDataMock } from '../../../mock/models/genetic-analysts/genetic-analyst-service.mock';
import { SecretKeyList } from '@common/secrets';

describe('Genetic Analysis Events', () => {
let app: INestApplication;
Expand All @@ -50,26 +49,6 @@ describe('Genetic Analysis Events', () => {
error: jest.fn(),
};

class GoogleSecretManagerServiceMock {
_secretsList = new Map<string, string>([
['ELASTICSEARCH_NODE', process.env.ELASTICSEARCH_NODE],
['ELASTICSEARCH_USERNAME', process.env.ELASTICSEARCH_USERNAME],
['ELASTICSEARCH_PASSWORD', process.env.ELASTICSEARCH_PASSWORD],
['SUBSTRATE_URL', process.env.SUBSTRATE_URL],
['ADMIN_SUBSTRATE_MNEMONIC', process.env.ADMIN_SUBSTRATE_MNEMONIC],
['EMAIL', process.env.EMAIL],
['PASS_EMAIL', process.env.PASS_EMAIL],
]);

loadSecrets() {
return null;
}

getSecret(key) {
return this._secretsList.get(key);
}
}

beforeAll(async () => {
const module: TestingModule = await Test.createTestingModule({
imports: [
Expand All @@ -80,8 +59,7 @@ describe('Genetic Analysis Events', () => {
IndexerModule,
],
providers: [IndexerHandler],
})
.compile();
}).compile();

elasticsearchService =
module.get<ElasticsearchService>(ElasticsearchService);
Expand Down
Loading

0 comments on commit 137797f

Please sign in to comment.