fix(cms): add Payload REST API + GraphQL route handlers, revert to inline serverFunction
This commit is contained in:
19
apps/cms/src/app/(payload)/api/[...slug]/route.ts
Normal file
19
apps/cms/src/app/(payload)/api/[...slug]/route.ts
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
/* THIS FILE WAS GENERATED AUTOMATICALLY BY PAYLOAD. */
|
||||||
|
/* DO NOT MODIFY IT BECAUSE IT COULD BE REWRITTEN AT ANY TIME. */
|
||||||
|
import config from "@payload-config";
|
||||||
|
import "@payloadcms/next/css";
|
||||||
|
import {
|
||||||
|
REST_DELETE,
|
||||||
|
REST_GET,
|
||||||
|
REST_OPTIONS,
|
||||||
|
REST_PATCH,
|
||||||
|
REST_POST,
|
||||||
|
REST_PUT,
|
||||||
|
} from "@payloadcms/next/routes";
|
||||||
|
|
||||||
|
export const GET = REST_GET(config);
|
||||||
|
export const POST = REST_POST(config);
|
||||||
|
export const DELETE = REST_DELETE(config);
|
||||||
|
export const PATCH = REST_PATCH(config);
|
||||||
|
export const PUT = REST_PUT(config);
|
||||||
|
export const OPTIONS = REST_OPTIONS(config);
|
||||||
6
apps/cms/src/app/(payload)/api/graphql/route.ts
Normal file
6
apps/cms/src/app/(payload)/api/graphql/route.ts
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
/* THIS FILE WAS GENERATED AUTOMATICALLY BY PAYLOAD. */
|
||||||
|
/* DO NOT MODIFY IT BECAUSE IT COULD BE REWRITTEN AT ANY TIME. */
|
||||||
|
import config from "@payload-config";
|
||||||
|
import { GRAPHQL_POST } from "@payloadcms/next/routes";
|
||||||
|
|
||||||
|
export const POST = GRAPHQL_POST(config);
|
||||||
@@ -2,17 +2,26 @@
|
|||||||
/* DO NOT MODIFY IT BECAUSE IT COULD BE REWRITTEN AT ANY TIME. */
|
/* DO NOT MODIFY IT BECAUSE IT COULD BE REWRITTEN AT ANY TIME. */
|
||||||
import config from "@payload-config";
|
import config from "@payload-config";
|
||||||
import "@payloadcms/next/css";
|
import "@payloadcms/next/css";
|
||||||
import { RootLayout } from "@payloadcms/next/layouts";
|
import type { ServerFunctionClient } from "payload";
|
||||||
|
import { handleServerFunctions, RootLayout } from "@payloadcms/next/layouts";
|
||||||
import React from "react";
|
import React from "react";
|
||||||
|
|
||||||
import { importMap } from "./admin/importMap.js";
|
import { importMap } from "./admin/importMap.js";
|
||||||
import { serverFunction } from "./serverFunction";
|
|
||||||
import "./custom.scss";
|
import "./custom.scss";
|
||||||
|
|
||||||
type Args = {
|
type Args = {
|
||||||
children: React.ReactNode;
|
children: React.ReactNode;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const serverFunction: ServerFunctionClient = async function (args) {
|
||||||
|
"use server";
|
||||||
|
return handleServerFunctions({
|
||||||
|
...args,
|
||||||
|
config,
|
||||||
|
importMap,
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
const Layout = ({ children }: Args) => (
|
const Layout = ({ children }: Args) => (
|
||||||
<RootLayout
|
<RootLayout
|
||||||
config={config}
|
config={config}
|
||||||
|
|||||||
@@ -1,14 +0,0 @@
|
|||||||
"use server";
|
|
||||||
|
|
||||||
import config from "@payload-config";
|
|
||||||
import { handleServerFunctions } from "@payloadcms/next/layouts";
|
|
||||||
import { importMap } from "./admin/importMap.js";
|
|
||||||
import type { ServerFunctionClient } from "payload";
|
|
||||||
|
|
||||||
export const serverFunction: ServerFunctionClient = async (args) => {
|
|
||||||
return handleServerFunctions({
|
|
||||||
...args,
|
|
||||||
config,
|
|
||||||
importMap,
|
|
||||||
});
|
|
||||||
};
|
|
||||||
Reference in New Issue
Block a user