Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 | import { TransactionsService } from "@billos/firefly-iii-sdk"
import { NextFunction, Request, Response } from "express"
import pino from "pino"
import { client } from "../client"
const logger = pino()
export async function AssertTransactionExistsMiddleware(req: Request<{ transactionId: string }>, res: Response, next: NextFunction) {
// Redirect to the transaction link
const { transactionId } = req.params
try {
await TransactionsService.getTransaction({ client, path: { id: transactionId } })
} catch (err) {
logger.error("Transaction not found for ID %s", transactionId)
return res.status(404).send("Transaction not found")
}
return next()
}
|