Typing all the types

This commit is contained in:
2024-10-23 00:27:20 +02:00
parent edaf5f5c71
commit 46ad9813eb
15 changed files with 97 additions and 105 deletions

View File

@@ -1,23 +1,21 @@
import { Context } from "@oak/oak";
import { nip19 } from "@nostr/tools";
import { log } from "../log.ts";
import { lookupUsernameByPubkey } from "../directory.ts";
import notFoundHandler from "../handlers/not-found.ts";
const npubHandler = async function (ctx: Context) {
const npub = ctx.params.path;
const npub = ctx.state.path;
try {
const r = nip19.decode(npub);
const username = await lookupUsernameByPubkey(r.data);
const pubkey = nip19.decode(npub).data as string;
const username = await lookupUsernameByPubkey(pubkey);
if (username) {
ctx.response.redirect(`/@${username}`);
} else {
notFoundHandler(ctx);
}
} catch (e) {
log(e, "yellow");
} catch (_e) {
notFoundHandler(ctx);
}
};