Typing all the types
This commit is contained in:
@@ -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);
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user