chore: adjust rest endpoints to use new query property on req
This commit is contained in:
@@ -4,15 +4,11 @@ import { getTranslation } from '@payloadcms/translations'
|
||||
import httpStatus from 'http-status'
|
||||
import { deleteOperation } from 'payload/operations'
|
||||
import { isNumber } from 'payload/utilities'
|
||||
import qs from 'qs'
|
||||
|
||||
import type { CollectionRouteHandler } from '../types.d.ts'
|
||||
|
||||
export const deleteDoc: CollectionRouteHandler = async ({ collection, req }) => {
|
||||
const { searchParams } = req
|
||||
|
||||
// parse using `qs` to handle `where` queries
|
||||
const { depth, where } = qs.parse(searchParams.toString()) as {
|
||||
const { depth, where } = req.query as {
|
||||
depth?: string
|
||||
where?: Where
|
||||
}
|
||||
|
||||
@@ -3,14 +3,11 @@ import type { Where } from 'payload/types'
|
||||
import httpStatus from 'http-status'
|
||||
import { findOperation } from 'payload/operations'
|
||||
import { isNumber } from 'payload/utilities'
|
||||
import qs from 'qs'
|
||||
|
||||
import type { CollectionRouteHandler } from '../types.d.ts'
|
||||
|
||||
export const find: CollectionRouteHandler = async ({ collection, req }) => {
|
||||
const { searchParams } = req
|
||||
// parse using `qs` to handle `where` queries
|
||||
const { depth, draft, limit, page, sort, where } = qs.parse(searchParams.toString()) as {
|
||||
const { depth, draft, limit, page, sort, where } = req.query as {
|
||||
depth?: string
|
||||
draft?: string
|
||||
limit?: string
|
||||
|
||||
@@ -3,15 +3,11 @@ import type { Where } from 'payload/types'
|
||||
import httpStatus from 'http-status'
|
||||
import { findVersionsOperation } from 'payload/operations'
|
||||
import { isNumber } from 'payload/utilities'
|
||||
import qs from 'qs'
|
||||
|
||||
import type { CollectionRouteHandler } from '../types.d.ts'
|
||||
|
||||
export const findVersions: CollectionRouteHandler = async ({ collection, req }) => {
|
||||
const { searchParams } = req
|
||||
|
||||
// parse using `qs` to handle `where` queries
|
||||
const { depth, limit, page, sort, where } = qs.parse(searchParams.toString()) as {
|
||||
const { depth, limit, page, sort, where } = req.query as {
|
||||
depth?: string
|
||||
limit?: string
|
||||
page?: string
|
||||
|
||||
@@ -4,15 +4,11 @@ import { getTranslation } from '@payloadcms/translations'
|
||||
import httpStatus from 'http-status'
|
||||
import { updateOperation } from 'payload/operations'
|
||||
import { isNumber } from 'payload/utilities'
|
||||
import qs from 'qs'
|
||||
|
||||
import type { CollectionRouteHandler } from '../types.d.ts'
|
||||
|
||||
export const update: CollectionRouteHandler = async ({ collection, req }) => {
|
||||
const { searchParams } = req
|
||||
|
||||
// parse using `qs` to handle `where` queries
|
||||
const { depth, draft, where } = qs.parse(searchParams.toString()) as {
|
||||
const { depth, draft, where } = req.query as {
|
||||
depth?: string
|
||||
draft?: string
|
||||
where?: Where
|
||||
|
||||
@@ -3,17 +3,12 @@ import type { Where } from 'payload/types'
|
||||
import httpStatus from 'http-status'
|
||||
import { findVersionsOperationGlobal } from 'payload/operations'
|
||||
import { isNumber } from 'payload/utilities'
|
||||
import qs from 'qs'
|
||||
|
||||
import type { GlobalRouteHandler } from '../types.d.ts'
|
||||
|
||||
export const findVersions: GlobalRouteHandler = async ({ globalConfig, req }) => {
|
||||
const { searchParams } = req
|
||||
|
||||
// parse using `qs` to handle `where` queries
|
||||
const { depth, draft, limit, page, sort, where } = qs.parse(searchParams.toString()) as {
|
||||
const { depth, limit, page, sort, where } = req.query as {
|
||||
depth?: string
|
||||
draft?: string
|
||||
limit?: string
|
||||
page?: string
|
||||
sort?: string
|
||||
|
||||
@@ -97,7 +97,12 @@ export const createPayloadRequest = async ({
|
||||
port: urlProperties.port,
|
||||
protocol: urlProperties.protocol,
|
||||
query: urlProperties.search
|
||||
? QueryString.parse(urlProperties.search, { strictNullHandling: true })
|
||||
? QueryString.parse(urlProperties.search, {
|
||||
arrayLimit: 1000,
|
||||
depth: 10,
|
||||
ignoreQueryPrefix: true,
|
||||
strictNullHandling: true,
|
||||
})
|
||||
: {},
|
||||
routeParams: params || {},
|
||||
search: urlProperties.search,
|
||||
|
||||
Reference in New Issue
Block a user