Some checks failed
Build & Deploy / 🔍 Prepare (push) Successful in 20s
Build & Deploy / 🧪 QA (push) Failing after 34s
Build & Deploy / 🏗️ Build (push) Has started running
Build & Deploy / 🚀 Deploy (push) Has been cancelled
Build & Deploy / 🧪 Smoke Test (push) Has been cancelled
Build & Deploy / ⚡ Lighthouse (push) Has been cancelled
Build & Deploy / 🔔 Notify (push) Has been cancelled
33 lines
1.1 KiB
Plaintext
33 lines
1.1 KiB
Plaintext
import { status as httpStatus } from 'http-status';
|
|
import { APIError } from '../../errors/APIError.js';
|
|
import { getRequestCollection } from '../../utilities/getRequestEntity.js';
|
|
import { headersWithCors } from '../../utilities/headersWithCors.js';
|
|
import { parseParams } from '../../utilities/parseParams/index.js';
|
|
import { findDistinctOperation } from '../operations/findDistinct.js';
|
|
export const findDistinctHandler = async (req)=>{
|
|
const collection = getRequestCollection(req);
|
|
const { depth, field, limit, page, sort, trash, where } = parseParams(req.query);
|
|
if (!field) {
|
|
throw new APIError('field must be specified', httpStatus.BAD_REQUEST);
|
|
}
|
|
const result = await findDistinctOperation({
|
|
collection,
|
|
depth,
|
|
field,
|
|
limit,
|
|
page,
|
|
req,
|
|
sort,
|
|
trash,
|
|
where
|
|
});
|
|
return Response.json(result, {
|
|
headers: headersWithCors({
|
|
headers: new Headers(),
|
|
req
|
|
}),
|
|
status: httpStatus.OK
|
|
});
|
|
};
|
|
|
|
//# sourceMappingURL=findDistinct.js.map |