mirror of
https://github.com/reiyua/github-profile-trophy-reiyua-mirror.git
synced 2026-11-17 06:02:09 +11:00
Improvements on workflow and files (#222)
* chore: improvements * chore: add testing workflow * fix: types and lint * chore: change dynamic * chore: improvements * chore: no need repository to check status
This commit is contained in:
parent
a4d50a11db
commit
5dc3379214
15 changed files with 446 additions and 224 deletions
22
.github/workflows/testing.yml
vendored
Normal file
22
.github/workflows/testing.yml
vendored
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
name: Check PR Test
|
||||
|
||||
on:
|
||||
pull_request:
|
||||
branches:
|
||||
- master
|
||||
jobs:
|
||||
install-dependencies:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Check if PR is in draft mode
|
||||
run: |
|
||||
if [ "${{ github.event.pull_request.draft }}" == "true" ]; then
|
||||
echo "PR is in draft mode, skipping workflow"
|
||||
exit 78
|
||||
fi
|
||||
- name: Set up Deno
|
||||
uses: denolib/setup-deno@v2
|
||||
with:
|
||||
deno-version: "1.37.0"
|
||||
- name: Run tests
|
||||
run: deno test --allow-env
|
||||
|
|
@ -498,3 +498,9 @@ https://github-profile-trophy.vercel.app/?username=ryo-ma&no-frame=true
|
|||
|
||||
# Contribution Guide
|
||||
Check [CONTRIBUTING.md](./CONTRIBUTING.md) for more details.
|
||||
|
||||
# Testing
|
||||
|
||||
```bash
|
||||
deno test --allow-env
|
||||
```
|
||||
|
|
|
|||
|
|
@ -1,28 +1,31 @@
|
|||
import { GithubAPIClient } from "./src/github_api_client.ts";
|
||||
import { Card } from "./src/card.ts";
|
||||
import { CONSTANTS, parseParams } from "./src/utils.ts";
|
||||
import { COLORS, Theme } from "./src/theme.ts";
|
||||
import { Error400, Error404 } from "./src/error_page.ts";
|
||||
import { Card } from "../src/card.ts";
|
||||
import { CONSTANTS, parseParams } from "../src/utils.ts";
|
||||
import { COLORS, Theme } from "../src/theme.ts";
|
||||
import { Error400, Error404 } from "../src/error_page.ts";
|
||||
import "https://deno.land/x/dotenv@v0.5.0/load.ts";
|
||||
import {staticRenderRegeneration} from "./src/StaticRenderRegeneration/index.ts";
|
||||
const apiEndpoint = Deno.env.get("GITHUB_API") || CONSTANTS.DEFAULT_GITHUB_API;
|
||||
const client = new GithubAPIClient(apiEndpoint);
|
||||
import { staticRenderRegeneration } from "../src/StaticRenderRegeneration/index.ts";
|
||||
import { GithubRepositoryService } from "../src/Repository/GithubRepository.ts";
|
||||
import { GithubApiService } from "../src/Services/GithubApiService.ts";
|
||||
|
||||
const serviceProvider = new GithubApiService();
|
||||
const client = new GithubRepositoryService(serviceProvider).repository;
|
||||
|
||||
const defaultHeaders = new Headers(
|
||||
{
|
||||
"Content-Type": "image/svg+xml",
|
||||
"Cache-Control": `public, max-age=${CONSTANTS.CACHE_MAX_AGE}`,
|
||||
},
|
||||
)
|
||||
);
|
||||
|
||||
export default (request: Request) => staticRenderRegeneration(request, {
|
||||
export default (request: Request) =>
|
||||
staticRenderRegeneration(request, {
|
||||
revalidate: CONSTANTS.REVALIDATE_TIME,
|
||||
headers: defaultHeaders
|
||||
}, function (req: Request) {
|
||||
headers: defaultHeaders,
|
||||
}, function (req: Request) {
|
||||
return app(req);
|
||||
});
|
||||
});
|
||||
|
||||
async function app (req: Request): Promise<Response>{
|
||||
async function app(req: Request): Promise<Response> {
|
||||
const params = parseParams(req);
|
||||
const username = params.get("username");
|
||||
const row = params.getNumberValue("row", CONSTANTS.DEFAULT_MAX_ROW);
|
||||
2
debug.ts
2
debug.ts
|
|
@ -1,4 +1,4 @@
|
|||
import { serve } from "https://deno.land/std@0.125.0/http/server.ts";
|
||||
import requestHandler from "./index.ts";
|
||||
import requestHandler from "./api/index.ts";
|
||||
|
||||
serve(requestHandler, { port: 8080 });
|
||||
|
|
|
|||
22
deps.ts
22
deps.ts
|
|
@ -1 +1,21 @@
|
|||
export { soxa } from "https://deno.land/x/soxa@1.4/mod.ts";
|
||||
import { Soxa as ServiceProvider } from "https://deno.land/x/soxa@1.4/src/core/Soxa.ts";
|
||||
import { defaults } from "https://deno.land/x/soxa@1.4/src/defaults.ts";
|
||||
import {
|
||||
assertEquals,
|
||||
assertRejects,
|
||||
} from "https://deno.land/std@0.203.0/assert/mod.ts";
|
||||
import {
|
||||
assertSpyCalls,
|
||||
spy,
|
||||
} from "https://deno.land/std@0.203.0/testing/mock.ts";
|
||||
|
||||
import { CONSTANTS } from "./src/utils.ts";
|
||||
|
||||
const baseURL = Deno.env.get("GITHUB_API") || CONSTANTS.DEFAULT_GITHUB_API;
|
||||
|
||||
const soxa = new ServiceProvider({
|
||||
...defaults,
|
||||
baseURL,
|
||||
});
|
||||
|
||||
export { assertEquals, assertRejects, assertSpyCalls, soxa, spy };
|
||||
|
|
|
|||
44
src/Helpers/Retry.ts
Normal file
44
src/Helpers/Retry.ts
Normal file
|
|
@ -0,0 +1,44 @@
|
|||
export type RetryCallbackProps = {
|
||||
attempt: number;
|
||||
};
|
||||
|
||||
type callbackType<T = unknown> = (data: RetryCallbackProps) => Promise<T> | T;
|
||||
|
||||
async function* createAsyncIterable<T>(
|
||||
callback: callbackType<T>,
|
||||
retries: number,
|
||||
delay: number,
|
||||
) {
|
||||
for (let i = 0; i < retries; i++) {
|
||||
try {
|
||||
const data = await callback({ attempt: i });
|
||||
yield data;
|
||||
return;
|
||||
} catch (e) {
|
||||
yield null;
|
||||
console.error(e);
|
||||
await new Promise((resolve) => setTimeout(resolve, delay));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export class Retry {
|
||||
constructor(private maxRetries = 2, private retryDelay = 1000) {}
|
||||
async fetch<T = unknown>(
|
||||
callback: callbackType<T>,
|
||||
) {
|
||||
for await (
|
||||
const callbackResult of createAsyncIterable<T>(
|
||||
callback,
|
||||
this.maxRetries,
|
||||
this.retryDelay,
|
||||
)
|
||||
) {
|
||||
if (callbackResult) {
|
||||
return callbackResult as T;
|
||||
}
|
||||
}
|
||||
|
||||
throw new Error(`Max retries (${this.maxRetries}) exceeded.`);
|
||||
}
|
||||
}
|
||||
66
src/Helpers/__tests__/Retry.test.ts
Normal file
66
src/Helpers/__tests__/Retry.test.ts
Normal file
|
|
@ -0,0 +1,66 @@
|
|||
import { Retry } from "../Retry.ts";
|
||||
import {
|
||||
assertEquals,
|
||||
assertRejects,
|
||||
assertSpyCalls,
|
||||
spy,
|
||||
} from "../../../deps.ts";
|
||||
|
||||
type MockResponse = {
|
||||
value: number;
|
||||
};
|
||||
|
||||
Deno.test("Retry.fetch", () => {
|
||||
const retryInstance = new Retry();
|
||||
const callback = spy(retryInstance, "fetch");
|
||||
|
||||
retryInstance.fetch<MockResponse>(() => {
|
||||
return { value: 1 };
|
||||
});
|
||||
|
||||
assertSpyCalls(callback, 1);
|
||||
});
|
||||
|
||||
Deno.test("Should retry", async () => {
|
||||
let countErrors = 0;
|
||||
|
||||
const callbackError = () => {
|
||||
countErrors++;
|
||||
throw new Error("Panic! Threw Error");
|
||||
};
|
||||
const retries = 3;
|
||||
const retryInstance = new Retry(retries);
|
||||
|
||||
await assertRejects(
|
||||
() => {
|
||||
return retryInstance.fetch<MockResponse>(callbackError);
|
||||
},
|
||||
Error,
|
||||
`Max retries (${retries}) exceeded.`,
|
||||
);
|
||||
|
||||
assertEquals(countErrors, 3);
|
||||
});
|
||||
|
||||
Deno.test("Should retry the asyncronous callback", async () => {
|
||||
let countErrors = 0;
|
||||
|
||||
const callbackError = async () => {
|
||||
countErrors++;
|
||||
// Mock request in callback
|
||||
await new Promise((_, reject) => setTimeout(reject, 100));
|
||||
};
|
||||
|
||||
const retries = 3;
|
||||
const retryInstance = new Retry(retries);
|
||||
|
||||
await assertRejects(
|
||||
() => {
|
||||
return retryInstance.fetch(callbackError);
|
||||
},
|
||||
Error,
|
||||
`Max retries (${retries}) exceeded.`,
|
||||
);
|
||||
|
||||
assertEquals(countErrors, 3);
|
||||
});
|
||||
25
src/Repository/GithubRepository.ts
Normal file
25
src/Repository/GithubRepository.ts
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
import {
|
||||
GitHubUserActivity,
|
||||
GitHubUserIssue,
|
||||
GitHubUserPullRequest,
|
||||
GitHubUserRepository,
|
||||
UserInfo,
|
||||
} from "../user_info.ts";
|
||||
|
||||
export abstract class GithubRepository {
|
||||
abstract requestUserInfo(username: string): Promise<UserInfo | null>;
|
||||
abstract requestUserActivity(
|
||||
username: string,
|
||||
): Promise<GitHubUserActivity | null>;
|
||||
abstract requestUserIssue(username: string): Promise<GitHubUserIssue | null>;
|
||||
abstract requestUserPullRequest(
|
||||
username: string,
|
||||
): Promise<GitHubUserPullRequest | null>;
|
||||
abstract requestUserRepository(
|
||||
username: string,
|
||||
): Promise<GitHubUserRepository | null>;
|
||||
}
|
||||
|
||||
export class GithubRepositoryService {
|
||||
constructor(public repository: GithubRepository) {}
|
||||
}
|
||||
61
src/Schemas/index.ts
Normal file
61
src/Schemas/index.ts
Normal file
|
|
@ -0,0 +1,61 @@
|
|||
export const queryUserActivity = `
|
||||
query userInfo($username: String!) {
|
||||
user(login: $username) {
|
||||
createdAt
|
||||
contributionsCollection {
|
||||
totalCommitContributions
|
||||
restrictedContributionsCount
|
||||
totalPullRequestReviewContributions
|
||||
}
|
||||
organizations(first: 1) {
|
||||
totalCount
|
||||
}
|
||||
followers(first: 1) {
|
||||
totalCount
|
||||
}
|
||||
}
|
||||
}
|
||||
`;
|
||||
|
||||
export const queryUserIssue = `
|
||||
query userInfo($username: String!) {
|
||||
user(login: $username) {
|
||||
openIssues: issues(states: OPEN) {
|
||||
totalCount
|
||||
}
|
||||
closedIssues: issues(states: CLOSED) {
|
||||
totalCount
|
||||
}
|
||||
}
|
||||
}
|
||||
`;
|
||||
|
||||
export const queryUserPullRequest = `
|
||||
query userInfo($username: String!) {
|
||||
user(login: $username) {
|
||||
pullRequests(first: 1) {
|
||||
totalCount
|
||||
}
|
||||
}
|
||||
}
|
||||
`;
|
||||
|
||||
export const queryUserRepository = `
|
||||
query userInfo($username: String!) {
|
||||
user(login: $username) {
|
||||
repositories(first: 100, ownerAffiliations: OWNER, orderBy: {direction: DESC, field: STARGAZERS}) {
|
||||
totalCount
|
||||
nodes {
|
||||
languages(first: 3, orderBy: {direction:DESC, field: SIZE}) {
|
||||
nodes {
|
||||
name
|
||||
}
|
||||
}
|
||||
stargazers {
|
||||
totalCount
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
`;
|
||||
120
src/Services/GithubApiService.ts
Normal file
120
src/Services/GithubApiService.ts
Normal file
|
|
@ -0,0 +1,120 @@
|
|||
import { GithubRepository } from "../Repository/GithubRepository.ts";
|
||||
import {
|
||||
GitHubUserActivity,
|
||||
GitHubUserIssue,
|
||||
GitHubUserPullRequest,
|
||||
GitHubUserRepository,
|
||||
UserInfo,
|
||||
} from "../user_info.ts";
|
||||
import {
|
||||
queryUserActivity,
|
||||
queryUserIssue,
|
||||
queryUserPullRequest,
|
||||
queryUserRepository,
|
||||
} from "../Schemas/index.ts";
|
||||
import { soxa } from "../../deps.ts";
|
||||
import { Retry } from "../Helpers/Retry.ts";
|
||||
import { QueryDefaultResponse } from "../Types/index.ts";
|
||||
import { CONSTANTS } from "../utils.ts";
|
||||
|
||||
// Need to be here - Exporting from another file makes array of null
|
||||
export const TOKENS = [
|
||||
Deno.env.get("GITHUB_TOKEN1"),
|
||||
Deno.env.get("GITHUB_TOKEN2"),
|
||||
];
|
||||
|
||||
export class GithubApiService extends GithubRepository {
|
||||
async requestUserRepository(
|
||||
username: string,
|
||||
): Promise<GitHubUserRepository | null> {
|
||||
return await this.executeQuery<GitHubUserRepository>(queryUserRepository, {
|
||||
username,
|
||||
});
|
||||
}
|
||||
async requestUserActivity(
|
||||
username: string,
|
||||
): Promise<GitHubUserActivity | null> {
|
||||
return await this.executeQuery<GitHubUserActivity>(queryUserActivity, {
|
||||
username,
|
||||
});
|
||||
}
|
||||
async requestUserIssue(username: string): Promise<GitHubUserIssue | null> {
|
||||
return await this.executeQuery<GitHubUserIssue>(queryUserIssue, {
|
||||
username,
|
||||
});
|
||||
}
|
||||
async requestUserPullRequest(
|
||||
username: string,
|
||||
): Promise<GitHubUserPullRequest | null> {
|
||||
return await this.executeQuery<GitHubUserPullRequest>(
|
||||
queryUserPullRequest,
|
||||
{ username },
|
||||
);
|
||||
}
|
||||
async requestUserInfo(username: string): Promise<UserInfo | null> {
|
||||
// Avoid to call others if one of them is null
|
||||
const repository = await this.requestUserRepository(username);
|
||||
if (repository === null) return null;
|
||||
|
||||
const promises = Promise.allSettled([
|
||||
this.requestUserActivity(username),
|
||||
this.requestUserIssue(username),
|
||||
this.requestUserPullRequest(username),
|
||||
]);
|
||||
const [activity, issue, pullRequest] = await promises;
|
||||
const status = [
|
||||
activity.status,
|
||||
issue.status,
|
||||
pullRequest.status,
|
||||
];
|
||||
|
||||
if (status.includes("rejected")) {
|
||||
console.error(`Can not find a user with username:' ${username}'`);
|
||||
return null;
|
||||
}
|
||||
|
||||
return new UserInfo(
|
||||
(activity as PromiseFulfilledResult<GitHubUserActivity>).value,
|
||||
(issue as PromiseFulfilledResult<GitHubUserIssue>).value,
|
||||
(pullRequest as PromiseFulfilledResult<GitHubUserPullRequest>).value,
|
||||
repository,
|
||||
);
|
||||
}
|
||||
|
||||
async executeQuery<T = unknown>(
|
||||
query: string,
|
||||
variables: { [key: string]: string },
|
||||
) {
|
||||
try {
|
||||
const retry = new Retry(
|
||||
TOKENS.length,
|
||||
CONSTANTS.DEFAULT_GITHUB_RETRY_DELAY,
|
||||
);
|
||||
const response = await retry.fetch<Promise<T>>(async ({ attempt }) => {
|
||||
return await soxa.post("", {}, {
|
||||
data: { query: query, variables },
|
||||
headers: {
|
||||
Authorization: `bearer ${TOKENS[attempt]}`,
|
||||
},
|
||||
});
|
||||
}) as QueryDefaultResponse<{ user: T; errors?: unknown[] }>;
|
||||
|
||||
if (response.data.data.errors) {
|
||||
throw new Error("Error from Github API", {
|
||||
cause: response.data.data.errors,
|
||||
});
|
||||
}
|
||||
|
||||
return response?.data?.data?.user ?? null;
|
||||
} catch (error) {
|
||||
// TODO: Move this to a logger instance later
|
||||
if (error instanceof Error && error.cause) {
|
||||
console.error(JSON.stringify(error.cause, null, 2));
|
||||
} else {
|
||||
console.error(error);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
import { existsSync } from './utils.ts'
|
||||
import { existsSync } from "./utils.ts";
|
||||
|
||||
export class CacheManager {
|
||||
constructor(private revalidateTime: number, private cacheFile: string) {}
|
||||
|
|
@ -33,17 +33,18 @@ export class CacheManager {
|
|||
return false;
|
||||
}
|
||||
const currentTime = new Date().getTime();
|
||||
return currentTime - this.cacheFileLastModifiedGetTime < this.revalidateTime;
|
||||
return currentTime - this.cacheFileLastModifiedGetTime <
|
||||
this.revalidateTime;
|
||||
}
|
||||
|
||||
async save (response: Response): Promise<void> {
|
||||
if(response === null) return
|
||||
async save(response: Response): Promise<void> {
|
||||
if (response === null) return;
|
||||
// Prevent TypeError: ReadableStream is locked
|
||||
const text = await response.clone().text()
|
||||
const data = new TextEncoder().encode(text)
|
||||
const text = await response.clone().text();
|
||||
const data = new TextEncoder().encode(text);
|
||||
|
||||
Deno.writeFile(this.cacheFilePath, data, { create: true }).catch(() => {
|
||||
console.warn("Failed to save cache file")
|
||||
console.warn("Failed to save cache file");
|
||||
});
|
||||
}
|
||||
}
|
||||
5
src/Types/Request.ts
Normal file
5
src/Types/Request.ts
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
export type QueryDefaultResponse<T = unknown> = {
|
||||
data: {
|
||||
data: T;
|
||||
};
|
||||
};
|
||||
1
src/Types/index.ts
Normal file
1
src/Types/index.ts
Normal file
|
|
@ -0,0 +1 @@
|
|||
export * from './Request.ts'
|
||||
|
|
@ -1,159 +0,0 @@
|
|||
import { soxa } from "../deps.ts";
|
||||
import { UserInfo } from "./user_info.ts";
|
||||
import { CONSTANTS } from "./utils.ts";
|
||||
import type {
|
||||
GitHubUserActivity,
|
||||
GitHubUserIssue,
|
||||
GitHubUserPullRequest,
|
||||
GitHubUserRepository,
|
||||
} from "./user_info.ts";
|
||||
|
||||
export class GithubAPIClient {
|
||||
constructor(
|
||||
private apiEndpoint: string = CONSTANTS.DEFAULT_GITHUB_API,
|
||||
) {
|
||||
}
|
||||
async requestUserInfo(
|
||||
username: string,
|
||||
): Promise<UserInfo | null> {
|
||||
// Avoid timeout for the Github API
|
||||
const results = await Promise.all([
|
||||
this.requestUserActivity(username),
|
||||
this.requestUserIssue(username),
|
||||
this.requestUserPullRequest(username),
|
||||
this.requestUserRepository(username),
|
||||
]);
|
||||
if (results.some((r) => r == null)) {
|
||||
console.error(`Can not find a user with username:'${username}'`);
|
||||
return null;
|
||||
}
|
||||
return new UserInfo(results[0]!, results[1]!, results[2]!, results[3]!);
|
||||
}
|
||||
private async requestUserActivity(
|
||||
username: string,
|
||||
): Promise<GitHubUserActivity | null> {
|
||||
const query = `
|
||||
query userInfo($username: String!) {
|
||||
user(login: $username) {
|
||||
createdAt
|
||||
contributionsCollection {
|
||||
totalCommitContributions
|
||||
restrictedContributionsCount
|
||||
totalPullRequestReviewContributions
|
||||
}
|
||||
organizations(first: 1) {
|
||||
totalCount
|
||||
}
|
||||
followers(first: 1) {
|
||||
totalCount
|
||||
}
|
||||
}
|
||||
}
|
||||
`;
|
||||
return await this.request(query, username);
|
||||
}
|
||||
private async requestUserIssue(
|
||||
username: string,
|
||||
): Promise<GitHubUserIssue | null> {
|
||||
const query = `
|
||||
query userInfo($username: String!) {
|
||||
user(login: $username) {
|
||||
openIssues: issues(states: OPEN) {
|
||||
totalCount
|
||||
}
|
||||
closedIssues: issues(states: CLOSED) {
|
||||
totalCount
|
||||
}
|
||||
}
|
||||
}
|
||||
`;
|
||||
return await this.request(query, username);
|
||||
}
|
||||
private async requestUserPullRequest(
|
||||
username: string,
|
||||
): Promise<GitHubUserPullRequest | null> {
|
||||
const query = `
|
||||
query userInfo($username: String!) {
|
||||
user(login: $username) {
|
||||
pullRequests(first: 1) {
|
||||
totalCount
|
||||
}
|
||||
}
|
||||
}
|
||||
`;
|
||||
return await this.request(query, username);
|
||||
}
|
||||
private async requestUserRepository(
|
||||
username: string,
|
||||
): Promise<GitHubUserRepository | null> {
|
||||
const query = `
|
||||
query userInfo($username: String!) {
|
||||
user(login: $username) {
|
||||
repositories(first: 100, ownerAffiliations: OWNER, orderBy: {direction: DESC, field: STARGAZERS}) {
|
||||
totalCount
|
||||
nodes {
|
||||
languages(first: 3, orderBy: {direction:DESC, field: SIZE}) {
|
||||
nodes {
|
||||
name
|
||||
}
|
||||
}
|
||||
stargazers {
|
||||
totalCount
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
`;
|
||||
return await this.request(query, username);
|
||||
}
|
||||
private async request(
|
||||
query: string,
|
||||
username: string,
|
||||
retryDelay = CONSTANTS.DEFAULT_GITHUB_RETRY_DELAY,
|
||||
) {
|
||||
const tokens = [
|
||||
Deno.env.get("GITHUB_TOKEN1"),
|
||||
Deno.env.get("GITHUB_TOKEN2"),
|
||||
];
|
||||
const maxRetries = tokens.length;
|
||||
|
||||
const variables = { username: username };
|
||||
let response;
|
||||
|
||||
for (let attempt = 0; attempt < maxRetries; attempt++) {
|
||||
try {
|
||||
response = await soxa.post(
|
||||
this.apiEndpoint,
|
||||
{},
|
||||
{
|
||||
data: { query: query, variables },
|
||||
headers: { Authorization: `bearer ${tokens[attempt]}` },
|
||||
},
|
||||
);
|
||||
if (response.data.errors !== undefined) {
|
||||
throw new Error(
|
||||
response.data.errors.map((e: { message: string; type: string }) =>
|
||||
e.message
|
||||
).join("\n"),
|
||||
);
|
||||
}
|
||||
if (response.data.data !== undefined) {
|
||||
return response.data.data.user;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
} catch (error) {
|
||||
console.error(
|
||||
`Attempt ${attempt} failed with GITHUB_TOKEN${attempt + 1}:`,
|
||||
error,
|
||||
);
|
||||
}
|
||||
|
||||
console.log(`Retrying in ${retryDelay / 1000} seconds...`);
|
||||
await new Promise((resolve) => setTimeout(resolve, retryDelay));
|
||||
}
|
||||
|
||||
throw new Error(`Max retries (${maxRetries}) exceeded.`);
|
||||
}
|
||||
}
|
||||
17
vercel.json
17
vercel.json
|
|
@ -1,7 +1,14 @@
|
|||
{
|
||||
"builds":[{
|
||||
"src": "**/index.ts",
|
||||
"use": "vercel-deno@1.1.1"
|
||||
}],
|
||||
"routes": [{ "src": "/.*", "dest": "/" }]
|
||||
"public": true,
|
||||
"functions": {
|
||||
"api/**/*.[jt]s": {
|
||||
"runtime": "vercel-deno@3.0.4"
|
||||
}
|
||||
},
|
||||
"rewrites": [
|
||||
{
|
||||
"source": "/(.*)",
|
||||
"destination": "/api/$1"
|
||||
}
|
||||
]
|
||||
}
|
||||
Loading…
Add table
Reference in a new issue