Skip to content

Commit

Permalink
feat: Upgrade to v2 API
Browse files Browse the repository at this point in the history
Signed-off-by: John McBride <john@opensauced.pizza>
  • Loading branch information
jpmcb committed Jan 24, 2024
1 parent 5df0d42 commit 8e232a2
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 17 deletions.
18 changes: 9 additions & 9 deletions src/social-card/highlight-card/highlight-card.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,19 +35,19 @@ export class HighlightCardService {
private readonly logger = new Logger(this.constructor.name);
private fonts: Buffer[] = [];

constructor (
constructor(

Check failure on line 38 in src/social-card/highlight-card/highlight-card.service.ts

View workflow job for this annotation

GitHub Actions / test / Code standards

Missing space before function parentheses
private readonly httpService: HttpService,
private readonly githubService: GithubService,
private readonly s3FileStorageService: S3FileStorageService,
) {}
) { }

private async getHighlightData (highlightId: number): Promise<HighlightCardData> {
private async getHighlightData(highlightId: number): Promise<HighlightCardData> {

Check failure on line 44 in src/social-card/highlight-card/highlight-card.service.ts

View workflow job for this annotation

GitHub Actions / test / Code standards

Missing space before function parentheses
const highlightReq = firstValueFrom(
this.httpService.get<DbUserHighlight>(`${process.env.API_BASE_URL!}/v1/user/highlights/${highlightId}`),
this.httpService.get<DbUserHighlight>(`${process.env.API_BASE_URL!}/v2/user/highlights/${highlightId}`),
);

const reactionsReq = firstValueFrom(
this.httpService.get<DbReaction[]>(`${process.env.API_BASE_URL!}/v1/highlights/${highlightId}/reactions`),
this.httpService.get<DbReaction[]>(`${process.env.API_BASE_URL!}/v2/highlights/${highlightId}/reactions`),
);

const [highlight, highlightReactions] = await Promise.all([highlightReq, reactionsReq]);
Expand Down Expand Up @@ -81,7 +81,7 @@ export class HighlightCardService {
};
}

private async getFonts () {
private async getFonts() {

Check failure on line 84 in src/social-card/highlight-card/highlight-card.service.ts

View workflow job for this annotation

GitHub Actions / test / Code standards

Missing space before function parentheses
if (this.fonts.length === 0) {
const interArrayBufferReq = fs.readFile("node_modules/@fontsource/inter/files/inter-all-400-normal.woff");
const interArrayBufferMediumReq = fs.readFile("node_modules/@fontsource/inter/files/inter-all-500-normal.woff");
Expand All @@ -93,7 +93,7 @@ export class HighlightCardService {
}

// public only to be used in local scripts. Not for controller direct use.
async generateCardBuffer (highlightId: number, highlightData?: HighlightCardData) {
async generateCardBuffer(highlightId: number, highlightData?: HighlightCardData) {

Check failure on line 96 in src/social-card/highlight-card/highlight-card.service.ts

View workflow job for this annotation

GitHub Actions / test / Code standards

Missing space before function parentheses
const { html } = await import("satori-html");
const satori = (await import("satori")).default;

Expand Down Expand Up @@ -144,7 +144,7 @@ export class HighlightCardService {
return { png: pngData.asPng(), svg };
}

async checkRequiresUpdate (id: number): Promise<RequiresUpdateMeta> {
async checkRequiresUpdate(id: number): Promise<RequiresUpdateMeta> {

Check failure on line 147 in src/social-card/highlight-card/highlight-card.service.ts

View workflow job for this annotation

GitHub Actions / test / Code standards

Missing space before function parentheses
const hash = `highlights/${String(id)}.png`;
const fileUrl = `${this.s3FileStorageService.getCdnEndpoint()}${hash}`;
const hasFile = await this.s3FileStorageService.fileExists(hash);
Expand Down Expand Up @@ -180,7 +180,7 @@ export class HighlightCardService {
return returnVal;
}

async getHighlightCard (id: number): Promise<Buffer> {
async getHighlightCard(id: number): Promise<Buffer> {

Check failure on line 183 in src/social-card/highlight-card/highlight-card.service.ts

View workflow job for this annotation

GitHub Actions / test / Code standards

Missing space before function parentheses
const { remaining } = await this.githubService.rateLimit();

if (remaining < 1000) {
Expand Down
16 changes: 8 additions & 8 deletions src/social-card/insight-card/insight-card.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,17 +25,17 @@ interface InsightCardData {
export class InsightCardService {
private readonly logger = new Logger(this.constructor.name);

constructor (
constructor(

Check failure on line 28 in src/social-card/insight-card/insight-card.service.ts

View workflow job for this annotation

GitHub Actions / test / Code standards

Missing space before function parentheses
private readonly httpService: HttpService,
private readonly githubService: GithubService,
private readonly s3FileStorageService: S3FileStorageService,
) {}
) { }

private async getInsightData (insightId: number): Promise<InsightCardData> {
private async getInsightData(insightId: number): Promise<InsightCardData> {

Check failure on line 34 in src/social-card/insight-card/insight-card.service.ts

View workflow job for this annotation

GitHub Actions / test / Code standards

Missing space before function parentheses
const maxRepoQueryIdsLenght = 10;

const insightPageReq = await firstValueFrom(
this.httpService.get<DbInsight>(`${process.env.API_BASE_URL!}/v1/insights/${insightId}`),
this.httpService.get<DbInsight>(`${process.env.API_BASE_URL!}/v2/insights/${insightId}`),
);

const { repos, name, updated_at } = insightPageReq.data;
Expand All @@ -52,7 +52,7 @@ export class InsightCardService {

const contributorsReq = await firstValueFrom(
this.httpService.get<{ data: { author_login: string }[] }>(
`${process.env.API_BASE_URL!}/v1/contributors/search?${String(query)}`,
`${process.env.API_BASE_URL!}/v2/contributors/search?${String(query)}`,
),
);

Expand All @@ -79,7 +79,7 @@ export class InsightCardService {
}

// public only to be used in local scripts. Not for controller direct use.
async generateCardBuffer (insightId: number, insightData?: InsightCardData) {
async generateCardBuffer(insightId: number, insightData?: InsightCardData) {

Check failure on line 82 in src/social-card/insight-card/insight-card.service.ts

View workflow job for this annotation

GitHub Actions / test / Code standards

Missing space before function parentheses
const { html } = await import("satori-html");
const satori = (await import("satori")).default;

Expand Down Expand Up @@ -117,7 +117,7 @@ export class InsightCardService {
return { png: pngData.asPng(), svg };
}

async checkRequiresUpdate (id: number): Promise<RequiresUpdateMeta> {
async checkRequiresUpdate(id: number): Promise<RequiresUpdateMeta> {

Check failure on line 120 in src/social-card/insight-card/insight-card.service.ts

View workflow job for this annotation

GitHub Actions / test / Code standards

Missing space before function parentheses
const hash = `insights/${String(id)}.png`;
const fileUrl = `${this.s3FileStorageService.getCdnEndpoint()}${hash}`;
const hasFile = await this.s3FileStorageService.fileExists(hash);
Expand Down Expand Up @@ -147,7 +147,7 @@ export class InsightCardService {
return returnVal;
}

async getgetInsightCard (id: number): Promise<string> {
async getgetInsightCard(id: number): Promise<string> {
const { remaining } = await this.githubService.rateLimit();

if (remaining < 1000) {
Expand Down

0 comments on commit 8e232a2

Please sign in to comment.