import type { SimulationFunction } from '@x12i/api-simulator'; import { findBook } from '../state/checkout-ledger.js'; /** GET /books/:bookId -- a plain lookup, with a custom 404 when nothing matches. */ export const getBook: SimulationFunction = ({ request }) => { const bookId = request.params.bookId ?? ''; const book = findBook(bookId); if (!book) { return { status: 404, body: { error: 'BOOK_NOT_FOUND', message: `No book with id ${bookId}.` } }; } return { status: 200, body: book }; };