Browse Source

Merge branch 'main' into feature/add-snack-bar-to-copy-link-to-clipboard-action-in-access-table

pull/4175/head
Thomas Kaul 8 months ago
committed by GitHub
parent
commit
9de8f478c4
No known key found for this signature in database GPG Key ID: B5690EEEBB952194
  1. 6
      CHANGELOG.md
  2. 9
      apps/api/src/app/logo/logo.controller.ts
  3. 19
      apps/api/src/app/logo/logo.service.ts
  4. 211
      apps/api/src/assets/cryptocurrencies/cryptocurrencies.json

6
CHANGELOG.md

@ -10,12 +10,18 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Changed ### Changed
- Improved the usability of the _Copy link to clipboard_ action by adding a confirmation on success in the access table to share the portfolio - Improved the usability of the _Copy link to clipboard_ action by adding a confirmation on success in the access table to share the portfolio
- Improved the endpoint to fetch the logo of an asset or a platform by sending the original MIME type
- Eliminated `got` in favor of using `fetch` - Eliminated `got` in favor of using `fetch`
- Changed the `REDIS_HOST` from `localhost` to `redis` in `.env.example` - Changed the `REDIS_HOST` from `localhost` to `redis` in `.env.example`
- Changed the _Postgres_ host from `localhost` to `postgres` in `.env.example` - Changed the _Postgres_ host from `localhost` to `postgres` in `.env.example`
- Changed the _Postgres_ image from `postgres:15` to `postgres:15-alpine` in the `docker-compose` files - Changed the _Postgres_ image from `postgres:15` to `postgres:15-alpine` in the `docker-compose` files
- Introduced `extends` in the `docker-compose` files - Introduced `extends` in the `docker-compose` files
- Improved the language localization for German (`de`) - Improved the language localization for German (`de`)
- Refreshed the cryptocurrencies list
### Fixed
- Improved the handling of a missing url in the endpoint to fetch the logo of an asset or a platform
## 2.132.0 - 2024-12-30 ## 2.132.0 - 2024-12-30

9
apps/api/src/app/logo/logo.controller.ts

@ -26,12 +26,13 @@ export class LogoController {
@Res() response: Response @Res() response: Response
) { ) {
try { try {
const buffer = await this.logoService.getLogoByDataSourceAndSymbol({ const { buffer, type } =
await this.logoService.getLogoByDataSourceAndSymbol({
dataSource, dataSource,
symbol symbol
}); });
response.contentType('image/png'); response.contentType(type);
response.send(buffer); response.send(buffer);
} catch { } catch {
response.status(HttpStatus.NOT_FOUND).send(); response.status(HttpStatus.NOT_FOUND).send();
@ -44,9 +45,9 @@ export class LogoController {
@Res() response: Response @Res() response: Response
) { ) {
try { try {
const buffer = await this.logoService.getLogoByUrl(url); const { buffer, type } = await this.logoService.getLogoByUrl(url);
response.contentType('image/png'); response.contentType(type);
response.send(buffer); response.send(buffer);
} catch { } catch {
response.status(HttpStatus.NOT_FOUND).send(); response.status(HttpStatus.NOT_FOUND).send();

19
apps/api/src/app/logo/logo.service.ts

@ -28,7 +28,7 @@ export class LogoService {
{ dataSource, symbol } { dataSource, symbol }
]); ]);
if (!assetProfile) { if (!assetProfile?.url) {
throw new HttpException( throw new HttpException(
getReasonPhrase(StatusCodes.NOT_FOUND), getReasonPhrase(StatusCodes.NOT_FOUND),
StatusCodes.NOT_FOUND StatusCodes.NOT_FOUND
@ -38,12 +38,12 @@ export class LogoService {
return this.getBuffer(assetProfile.url); return this.getBuffer(assetProfile.url);
} }
public async getLogoByUrl(aUrl: string) { public getLogoByUrl(aUrl: string) {
return this.getBuffer(aUrl); return this.getBuffer(aUrl);
} }
private getBuffer(aUrl: string) { private async getBuffer(aUrl: string) {
return fetch( const blob = await fetch(
`https://t0.gstatic.com/faviconV2?client=SOCIAL&type=FAVICON&fallback_opts=TYPE,SIZE,URL&url=${aUrl}&size=64`, `https://t0.gstatic.com/faviconV2?client=SOCIAL&type=FAVICON&fallback_opts=TYPE,SIZE,URL&url=${aUrl}&size=64`,
{ {
headers: { 'User-Agent': 'request' }, headers: { 'User-Agent': 'request' },
@ -51,8 +51,13 @@ export class LogoService {
this.configurationService.get('REQUEST_TIMEOUT') this.configurationService.get('REQUEST_TIMEOUT')
) )
} }
) ).then((res) => res.blob());
.then((res) => res.arrayBuffer())
.then((buffer) => Buffer.from(buffer)); return {
buffer: await blob.arrayBuffer().then((arrayBuffer) => {
return Buffer.from(arrayBuffer);
}),
type: blob.type
};
} }
} }

211
apps/api/src/assets/cryptocurrencies/cryptocurrencies.json

File diff suppressed because it is too large
Loading…
Cancel
Save