UNPKG

@websolutespa/payload-plugin-bowl

Version:

Bowl PayloadCms plugin of the BOM Repository

28 lines (27 loc) 1.08 kB
import { isNumber } from '@websolutespa/bom-core'; import { status as HttpStatus } from 'http-status'; import { findByIDOperation, headersWithCors, sanitizeJoinParams, sanitizePopulateParam, sanitizeSelectParam } from 'payload'; import { getRequestCollectionWithID } from './getRequestCollection'; export const findByIDHandler = async (req)=>{ const { searchParams } = req; const { id, collection } = getRequestCollectionWithID(req); const depth = searchParams.get('depth'); const result = await findByIDOperation({ id, collection, depth: isNumber(depth) ? Number(depth) : undefined, draft: searchParams.get('draft') === 'true', joins: sanitizeJoinParams(req.query.joins), populate: sanitizePopulateParam(req.query.populate), req, select: sanitizeSelectParam(req.query.select) }); return Response.json(result, { headers: headersWithCors({ headers: new Headers(), req }), status: HttpStatus.OK }); }; //# sourceMappingURL=findByIDHandler.js.map