Compare commits
3 Commits
750c81f4cb
...
8a67f4fbdb
Author | SHA1 | Date | |
---|---|---|---|
8a67f4fbdb | |||
a208c40e06 | |||
073bc9f8e3 |
22
app.ts
22
app.ts
@ -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 {
|
import {
|
||||||
searchRepositoryWithTopic,
|
searchRepositoryWithTopic,
|
||||||
getRepositoryTags,
|
getRepositoryTags,
|
||||||
@ -156,9 +156,27 @@ app.use(async (ctx, next) => {
|
|||||||
app.use(router.routes());
|
app.use(router.routes());
|
||||||
app.use(router.allowedMethods());
|
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) => {
|
//app.use(async (ctx, next) => {
|
||||||
// ctx.throw(404);
|
// ctx.throw(404);
|
||||||
// //ctx.response.status = 404;
|
|
||||||
// //ctx.response.body = "Not Found";
|
// //ctx.response.body = "Not Found";
|
||||||
// //await next();
|
// //await next();
|
||||||
//});
|
//});
|
||||||
|
2
gitea.ts
2
gitea.ts
@ -43,7 +43,7 @@ export async function getRepositoryContent(owner:string,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (import.meta.main) {
|
if (import.meta.main) {
|
||||||
const results = await searchRepositoryWithTopic("deno");
|
const results = await searchRepositoryWithTopic("denolib");
|
||||||
console.log(results.data?.map((repo) => repo.full_name));
|
console.log(results.data?.map((repo) => repo.full_name));
|
||||||
const s = await getRepositoryContent("monoid", "script", "", "");
|
const s = await getRepositoryContent("monoid", "script", "", "");
|
||||||
console.log((s as ContentsResponse[]).map((x) => x.name));
|
console.log((s as ContentsResponse[]).map((x) => x.name));
|
||||||
|
Loading…
Reference in New Issue
Block a user