ghostfolio/apps/api/src/services/cryptocurrency/cryptocurrency.service.ts
Thomas Kaul 4cb9a3b142
Feature/refresh cryptocurrencies list (#998)
* Use cryptocurrencies list instead of outdated npm package

* Update changelog
2022-06-11 12:54:58 +02:00

28 lines
807 B
TypeScript

import { Injectable } from '@nestjs/common';
const cryptocurrencies = require('../../assets/cryptocurrencies/cryptocurrencies.json');
const customCryptocurrencies = require('../../assets/cryptocurrencies/custom.json');
@Injectable()
export class CryptocurrencyService {
private combinedCryptocurrencies: string[];
public constructor() {}
public isCryptocurrency(aSymbol = '') {
const cryptocurrencySymbol = aSymbol.substring(0, aSymbol.length - 3);
return this.getCryptocurrencies().includes(cryptocurrencySymbol);
}
private getCryptocurrencies() {
if (!this.combinedCryptocurrencies) {
this.combinedCryptocurrencies = [
...Object.keys(cryptocurrencies),
...Object.keys(customCryptocurrencies)
];
}
return this.combinedCryptocurrencies;
}
}