-
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.
- Loading branch information
Showing
15 changed files
with
259 additions
and
58 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
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
22 changes: 0 additions & 22 deletions
22
apps/service-capital/src/service-capital.controller.spec.ts
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,14 @@ | ||
import { MongodbModule } from '@app/mongodb'; | ||
import { RedisModule } from '@app/redis'; | ||
import { RestModule } from '@app/rest'; | ||
import { Module } from '@nestjs/common'; | ||
import { ConfigModule } from '@nestjs/config'; | ||
import { ServiceCapitalController } from './service-capital.controller'; | ||
import { ServiceCapitalService } from './service-capital.service'; | ||
import { CapitalService } from './service-capital.service'; | ||
|
||
@Module({ | ||
imports: [], | ||
imports: [ConfigModule.forRoot({ isGlobal: true }), MongodbModule, RedisModule, RestModule], | ||
controllers: [ServiceCapitalController], | ||
providers: [ServiceCapitalService], | ||
providers: [CapitalService], | ||
}) | ||
export class ServiceCapitalModule {} |
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 |
---|---|---|
@@ -0,0 +1,3 @@ | ||
import { APICapitalRaidSeason } from 'clashofclans.js'; | ||
|
||
export interface CapitalRaidSeasonsEntity extends APICapitalRaidSeason {} |
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,9 +1,3 @@ | ||
export class ClanStoresEntity { | ||
guildId: string; | ||
import { APIClanWar } from 'clashofclans.js'; | ||
|
||
name: string; | ||
|
||
tag: string; | ||
|
||
createdAt: Date; | ||
} | ||
export interface ClanWarsEntity extends APIClanWar {} |
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,8 +1,30 @@ | ||
import { Tokens } from '@app/constants'; | ||
import { RedisKeyPrefixes, Tokens } from '@app/constants'; | ||
import { Inject, Injectable } from '@nestjs/common'; | ||
import { APIClan } from 'clashofclans.js'; | ||
import { RedisClient } from './redis.module'; | ||
|
||
export const getRedisKey = (prefix: RedisKeyPrefixes, key: string): string => { | ||
return `${prefix}:${key}`; | ||
}; | ||
|
||
@Injectable() | ||
export class RedisService { | ||
constructor(@Inject(Tokens.REDIS) private readonly redis: RedisClient) {} | ||
|
||
async getTrackedClans(): Promise<TrackedClanList[]> { | ||
const result = await this.redis.json.get(getRedisKey(RedisKeyPrefixes.LINKED_CLANS, 'ALL')); | ||
return (result ?? []) as unknown as TrackedClanList[]; | ||
} | ||
|
||
async getClan(clanTag: string): Promise<APIClan | null> { | ||
const result = await this.redis.json.get(getRedisKey(RedisKeyPrefixes.CLAN, clanTag)); | ||
return result as unknown as APIClan; | ||
} | ||
} | ||
|
||
export interface TrackedClanList { | ||
clan: string; | ||
tag: string; | ||
isPatron: boolean; | ||
guildIds: string[]; | ||
} |
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
Oops, something went wrong.