import { isString } from '@weco/common/utils/array' ; import type { NextApiRequest , NextApiResponse } from 'next' ; import { fetchSeriesById } from 'services/prismic/fetch/series' ; import { createClient } from '../../../services/prismic/fetch' ; import { SeriesPrismicDocument } from '../../../services/prismic/types/series' ; type Data = SeriesPrismicDocument ; type NotFound = { notFound : true ; } ; export default async ( req , res ) => { const { id } = req . query ; if ( ! isString ( id ) ) { return res . status ( 404 ) . json ( { notFound : true } ) ; } const client = createClient ( { req } ) ; const response = await fetchSeriesById ( client , id ) ; if ( response ) { return res . status ( 200 ) . json ( response ) ; } return res . status ( 404 ) . json ( { notFound : true } ) ; } ;