Add messages to HTTPException's

This commit is contained in:
Alex Gleason 2023-09-10 19:43:07 -05:00
parent 75dd2652d2
commit 0adb6f5eba
No known key found for this signature in database
GPG Key ID: 7211D1F99744FBB7
3 changed files with 3 additions and 3 deletions

View File

@ -38,7 +38,7 @@ const auth19: AppMiddleware = async (c, next) => {
/** Throw a 401 if the pubkey isn't set. */ /** Throw a 401 if the pubkey isn't set. */
const requirePubkey: AppMiddleware = async (c, next) => { const requirePubkey: AppMiddleware = async (c, next) => {
if (!c.get('pubkey')) { if (!c.get('pubkey')) {
throw new HTTPException(401); throw new HTTPException(401, { message: 'No pubkey provided' });
} }
await next(); await next();

View File

@ -81,7 +81,7 @@ function withProof(
c.set('proof', proof); c.set('proof', proof);
await handler(c, proof, next); await handler(c, proof, next);
} else { } else {
throw new HTTPException(401); throw new HTTPException(401, { message: 'No proof' });
} }
}; };
} }

View File

@ -36,7 +36,7 @@ async function signNostrConnect<K extends number = number>(event: EventTemplate<
const pubkey = c.get('pubkey'); const pubkey = c.get('pubkey');
if (!pubkey) { if (!pubkey) {
throw new HTTPException(401); throw new HTTPException(401, { message: 'Missing pubkey' });
} }
const messageId = crypto.randomUUID(); const messageId = crypto.randomUUID();