search_awesome/api/repo.ts
2022-11-29 01:52:44 +09:00

75 lines
1.9 KiB
TypeScript

export interface RepoData {
name: string;
author: string;
description: string;
url: string;
stars: number;
forks: number;
tags: string[];
readme: string;
}
export const SAMPLE_DATA: RepoData[] = [
{
name: "deno",
author: "denoland",
description: "A secure runtime for JavaScript and TypeScript.",
url: "https://github.com/denoland/deno",
stars: 10000,
forks: 1000,
tags: ["deno", "runtime", "typescript"],
readme: `# Deno 🦕
Deno is a simple, modern and secure runtime for JavaScript and TypeScript that uses V8 and is built in Rust.
`,
},
{
name: "deno_std",
author: "denoland",
description: "Standard modules for the Deno runtime.",
url: "https://github.com/denoland/deno_std",
stars: 1000,
forks: 100,
tags: ["deno", "runtime", "typescript"],
readme: `# Deno Standard Modules 🦕
This repository contains the standard modules that are provided by default with Deno.
`,
},
{
name: "deno_website2",
author: "maximousblk",
description: "The new deno.land website.",
url: "https://github.com/maximousblk/deno_website2",
stars: 100,
forks: 10,
tags: ["deno", "website", "typescript"],
readme: `# Deno Website 2 🦕
The new deno.land website.
`,
}
]
export const getRepos = async (): Promise<RepoData[]> => {
// return mock data for now
return SAMPLE_DATA;
}
export interface SearchOptions {
/**
* The limit of results to return.
* @default 10
* @minimum 1
* @maximum 100
*/
limit?: number;
/**
* The offset of results to return.
* @default 0
*/
offset?: number;
}
export async function searchRepos(query: string, options?: SearchOptions): Promise<RepoData[]> {
// return mock data for now
return SAMPLE_DATA;
}