Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Keep backward compatibility on v token price endpoint #146

Merged
merged 2 commits into from
Mar 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/controllers/TokenStatsController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,8 @@ export class TokenStatsController extends ControllerBase implements IControllerB
const currency = req.query.currency as string | undefined;
res.json(await this._priceProvider.getPrice(req.params.symbol, currency));
} catch (err) {
this.handleError(res, err as Error);
// For the sake of backward compatibility
res.json(0);
}
});

Expand Down
3 changes: 1 addition & 2 deletions src/services/CacheService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export class CacheService<T> {

constructor(private cachedItemValidityTimeMs: number = 60000) {}

public getItem(key: string): CacheItem<T> | undefined{
public getItem(key: string): CacheItem<T> | undefined {
Guard.ThrowIfUndefined('key', key);

const cacheItem = this.cache.get(key);
Expand All @@ -24,7 +24,6 @@ export class CacheService<T> {

public setItem(key: string, item: T): void {
Guard.ThrowIfUndefined('key', key);
Guard.ThrowIfUndefined('item', item);

this.cache.set(key, {
data: item,
Expand Down
2 changes: 1 addition & 1 deletion src/services/CoinGeckoPriceProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ export class CoinGeckoPriceProvider implements IPriceProvider {
return 0;
}

public async getPriceWithTimestamp(symbol: string, currency: string | undefined): Promise<TokenInfo>{
public async getPriceWithTimestamp(symbol: string, currency: string | undefined): Promise<TokenInfo> {
const price = await this.getPrice(symbol, currency);

return {
Expand Down
3 changes: 1 addition & 2 deletions src/services/IPriceProvider.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
export type TokenInfo = {
price: number;
lastUpdated: number;
}

};

/**
* Definition of provider for access token price.
Expand Down
Loading