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
37 lines
1.2 KiB
Plaintext
37 lines
1.2 KiB
Plaintext
import { getTranslation } from '@payloadcms/translations';
|
|
import { status as httpStatus } from 'http-status';
|
|
import { getRequestCollection } from '../../utilities/getRequestEntity.js';
|
|
import { headersWithCors } from '../../utilities/headersWithCors.js';
|
|
import { parseParams } from '../../utilities/parseParams/index.js';
|
|
import { createOperation } from '../operations/create.js';
|
|
export const createHandler = async (req)=>{
|
|
const collection = getRequestCollection(req);
|
|
const { autosave, depth, draft, populate, publishAllLocales, select } = parseParams(req.query);
|
|
const publishSpecificLocale = req.query.publishSpecificLocale;
|
|
const doc = await createOperation({
|
|
autosave,
|
|
collection,
|
|
data: req.data,
|
|
depth,
|
|
draft,
|
|
populate,
|
|
publishAllLocales,
|
|
publishSpecificLocale,
|
|
req,
|
|
select
|
|
});
|
|
return Response.json({
|
|
doc,
|
|
message: req.t('general:successfullyCreated', {
|
|
label: getTranslation(collection.config.labels.singular, req.i18n)
|
|
})
|
|
}, {
|
|
headers: headersWithCors({
|
|
headers: new Headers(),
|
|
req
|
|
}),
|
|
status: httpStatus.CREATED
|
|
});
|
|
};
|
|
|
|
//# sourceMappingURL=create.js.map |