Skip to content

Commit

Permalink
fix: correct docker build
Browse files Browse the repository at this point in the history
  • Loading branch information
0-vortex committed Apr 3, 2023
1 parent 1894383 commit b62c129
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 2 deletions.
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,6 @@ RUN npm ci --omit=dev,optional,peer

COPY --from=builder --chown=node:node /usr/src/app/dist ./dist

EXPOSE 3004
EXPOSE 3001

CMD ["node", "dist/main"]
15 changes: 14 additions & 1 deletion src/github/github.service.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Inject, Injectable, Logger } from "@nestjs/common";
import { ConfigType } from "@nestjs/config";
import { graphql } from "@octokit/graphql";
import { User } from "@octokit/graphql-schema";
import { RateLimit, User } from "@octokit/graphql-schema";

import GithubConfig from "../config/github.config";
import getUser from "./gql/get-user";
Expand All @@ -28,4 +28,17 @@ export class GithubService {

return user;
}

async rateLimit () {
const { rateLimit } = await this.graphqlWithAuth<{ rateLimit: RateLimit }>(`query {
rateLimit {
limit,
cost,
remaining,
resetAt
}
}`);

return rateLimit;
}
}
6 changes: 6 additions & 0 deletions src/social-card/social-card.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,12 @@ export class SocialCardService {
}

async getUserCard (username: string): Promise<Buffer> {
const { remaining } = await this.githubService.rateLimit();

if (remaining < 1000) {
throw new Error("Rate limit exceeded");
}

const { html } = await import("satori-html");
const satori = (await import("satori")).default;

Expand Down

0 comments on commit b62c129

Please sign in to comment.