Files
Reactive-Resume/server/src/fonts/fonts.service.ts
T
Amruth Pillai 9c1380f401 🚀 release v3.0.0
2022-03-06 22:48:29 +01:00

22 lines
718 B
TypeScript

import { HttpService } from '@nestjs/axios';
import { Injectable } from '@nestjs/common';
import { ConfigService } from '@nestjs/config';
import { Font } from '@reactive-resume/schema';
import { get } from 'lodash';
import { firstValueFrom } from 'rxjs';
@Injectable()
export class FontsService {
constructor(private configService: ConfigService, private httpService: HttpService) {}
async getAll(): Promise<Font[]> {
const apiKey = this.configService.get<string>('google.apiKey');
const url = 'https://www.googleapis.com/webfonts/v1/webfonts?key=' + apiKey;
const response = await firstValueFrom(this.httpService.get(url));
const data = get(response.data, 'items', []);
return data;
}
}