Compare commits

..

3 Commits

2 changed files with 30 additions and 12 deletions

22
app.ts
View File

@ -1,4 +1,4 @@
import { Application, Router, HttpError, isHttpError } from "https://deno.land/x/oak@v12.1.0/mod.ts";
import { Application, Router, isHttpError } from "https://deno.land/x/oak@v12.1.0/mod.ts";
import {
searchRepositoryWithTopic,
getRepositoryTags,
@ -156,9 +156,27 @@ app.use(async (ctx, next) => {
app.use(router.routes());
app.use(router.allowedMethods());
app.use(async (ctx, next) => {
try {
await next();
}
catch (err) {
console.log(err);
if (isHttpError(err)) {
ctx.response.status = err.status;
const { message, status, stack } = err;
ctx.response.body = { message, status, stack };
}
else {
throw err;
}
}
});
//app.use(async (ctx, next) => {
// ctx.throw(404);
// //ctx.response.status = 404;
// //ctx.response.body = "Not Found";
// //await next();
//});

View File

@ -43,7 +43,7 @@ export async function getRepositoryContent(owner:string,
}
if (import.meta.main) {
const results = await searchRepositoryWithTopic("deno");
const results = await searchRepositoryWithTopic("denolib");
console.log(results.data?.map((repo) => repo.full_name));
const s = await getRepositoryContent("monoid", "script", "", "");
console.log((s as ContentsResponse[]).map((x) => x.name));