UNPKG

payload

Version:

Node, React, Headless CMS and Application Framework built on Next.js

32 lines (31 loc) 1.4 kB
import { status as httpStatus } from 'http-status'; import { getRequestCollection } from '../../utilities/getRequestEntity.js'; import { headersWithCors } from '../../utilities/headersWithCors.js'; import { isNumber } from '../../utilities/isNumber.js'; import { sanitizePopulateParam } from '../../utilities/sanitizePopulateParam.js'; import { sanitizeSelectParam } from '../../utilities/sanitizeSelectParam.js'; import { findVersionsOperation } from '../operations/findVersions.js'; export const findVersionsHandler = async (req)=>{ const collection = getRequestCollection(req); const { depth, limit, page, pagination, populate, select, sort, where } = req.query; const result = await findVersionsOperation({ collection, depth: isNumber(depth) ? Number(depth) : undefined, limit: isNumber(limit) ? Number(limit) : undefined, page: isNumber(page) ? Number(page) : undefined, pagination: pagination === 'false' ? false : undefined, populate: sanitizePopulateParam(populate), req, select: sanitizeSelectParam(select), sort: typeof sort === 'string' ? sort.split(',') : undefined, where }); return Response.json(result, { headers: headersWithCors({ headers: new Headers(), req }), status: httpStatus.OK }); }; //# sourceMappingURL=findVersions.js.map