Skip to content

Commit

Permalink
chore: add 404
Browse files Browse the repository at this point in the history
  • Loading branch information
slowbackspace committed Feb 5, 2024
1 parent e150bed commit 9395333
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/routes/txs/hash/required-signers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { SQLQuery } from '../../../sql/index.js';
import * as QueryTypes from '../../../types/queries/tx.js';
import * as ResponseTypes from '../../../types/responses/tx.js';
import { getDbSync } from '../../../utils/database.js';
import { handle404 } from '@blockfrost/blockfrost-utils/lib/fastify.js';

async function route(fastify: FastifyInstance) {
fastify.route({
Expand All @@ -16,6 +17,15 @@ async function route(fastify: FastifyInstance) {
const clientDbSync = await getDbSync(fastify);

try {
const query404 = await clientDbSync.query<QueryTypes.ResultFound>(SQLQuery.get('txs_404'), [
request.params.hash,
]);

if (query404.rows.length === 0) {
clientDbSync.release();
return handle404(reply);
}

const { rows }: { rows: ResponseTypes.TxWitnesses } =
await clientDbSync.query<QueryTypes.TxWitnesses>(SQLQuery.get('txs_hash_wits'), [
request.params.hash,
Expand Down

0 comments on commit 9395333

Please sign in to comment.