19 lines
486 B
TypeScript
19 lines
486 B
TypeScript
import { Handlers } from "$fresh/server.ts";
|
|
import { searchRepos, getRepos } from "../../api/repo.ts";
|
|
|
|
export const handler: Handlers = {
|
|
async GET(req, _ctx) {
|
|
const url = new URL(req.url);
|
|
const q = url.searchParams.get("q");
|
|
const repos = q != null ? await searchRepos(q, {
|
|
limit: 10,
|
|
offset: 0
|
|
}) : await getRepos();
|
|
return new Response(JSON.stringify(repos), {
|
|
headers: {
|
|
"content-type": "application/json",
|
|
},
|
|
});
|
|
}
|
|
}
|