Merge commit 'refs/pull/863/head' of github.com:payloadcms/payload
This commit is contained in:
@@ -29,7 +29,7 @@ Each collection is mounted using its `slug` value. For example, if a collection'
|
||||
| `GET` | `/api/{collectionSlug}` | Find paginated documents |
|
||||
| `GET` | `/api/{collectionSlug}/:id` | Find a specific document by ID |
|
||||
| `POST` | `/api/{collectionSlug}` | Create a new document |
|
||||
| `PUT` | `/api/{collectionSlug}/:id` | Update a document by ID |
|
||||
| `PATCH` | `/api/{collectionSlug}/:id` | Update a document by ID |
|
||||
| `DELETE` | `/api/{collectionSlug}/:id` | Delete an existing document by ID |
|
||||
|
||||
##### Additional `find` query parameters
|
||||
|
||||
@@ -16,7 +16,7 @@ import findVersionByID from './requestHandlers/findVersionByID';
|
||||
import restoreVersion from './requestHandlers/restoreVersion';
|
||||
import deleteHandler from './requestHandlers/delete';
|
||||
import findByID from './requestHandlers/findByID';
|
||||
import update from './requestHandlers/update';
|
||||
import update, { deprecatedUpdate } from './requestHandlers/update';
|
||||
import logoutHandler from '../auth/requestHandlers/logout';
|
||||
|
||||
const buildEndpoints = (collection: SanitizedCollectionConfig): Endpoint[] => {
|
||||
@@ -122,6 +122,11 @@ const buildEndpoints = (collection: SanitizedCollectionConfig): Endpoint[] => {
|
||||
{
|
||||
path: '/:id',
|
||||
method: 'put',
|
||||
handler: deprecatedUpdate,
|
||||
},
|
||||
{
|
||||
path: '/:id',
|
||||
method: 'patch',
|
||||
handler: update,
|
||||
},
|
||||
{
|
||||
|
||||
@@ -9,6 +9,12 @@ export type UpdateResult = {
|
||||
doc: Document
|
||||
};
|
||||
|
||||
export async function deprecatedUpdate(req: PayloadRequest, res: Response, next: NextFunction): Promise<Response<UpdateResult> | void> {
|
||||
console.warn('The PUT method is deprecated and will no longer be supported in a future release. Please use the PATCH method for update requests.');
|
||||
|
||||
return updateHandler(req, res, next);
|
||||
}
|
||||
|
||||
export default async function updateHandler(req: PayloadRequest, res: Response, next: NextFunction): Promise<Response<UpdateResult> | void> {
|
||||
try {
|
||||
const draft = req.query.draft === 'true';
|
||||
|
||||
Reference in New Issue
Block a user