chore: uncomment out the example of a server component with local api running
This commit is contained in:
parent
59293846cb
commit
ed3563470c
@ -1,4 +1,4 @@
|
|||||||
import path from "path";
|
import path from 'path'
|
||||||
// import { postgresAdapter } from '@payloadcms/db-postgres'
|
// import { postgresAdapter } from '@payloadcms/db-postgres'
|
||||||
import {
|
import {
|
||||||
AlignFeature,
|
AlignFeature,
|
||||||
@ -17,50 +17,50 @@ import {
|
|||||||
RelationshipFeature,
|
RelationshipFeature,
|
||||||
UnorderedListFeature,
|
UnorderedListFeature,
|
||||||
UploadFeature,
|
UploadFeature,
|
||||||
} from "@payloadcms/richtext-lexical";
|
} from '@payloadcms/richtext-lexical'
|
||||||
//import { slateEditor } from '@payloadcms/richtext-slate'
|
//import { slateEditor } from '@payloadcms/richtext-slate'
|
||||||
import { mongooseAdapter } from "@payloadcms/db-mongodb";
|
import { mongooseAdapter } from '@payloadcms/db-mongodb'
|
||||||
import { buildConfig } from "payload/config";
|
import { buildConfig } from 'payload/config'
|
||||||
import sharp from "sharp";
|
import sharp from 'sharp'
|
||||||
import { fileURLToPath } from "url";
|
import { fileURLToPath } from 'url'
|
||||||
|
|
||||||
const filename = fileURLToPath(import.meta.url);
|
const filename = fileURLToPath(import.meta.url)
|
||||||
const dirname = path.dirname(filename);
|
const dirname = path.dirname(filename)
|
||||||
|
|
||||||
export default buildConfig({
|
export default buildConfig({
|
||||||
//editor: slateEditor({}),
|
//editor: slateEditor({}),
|
||||||
editor: lexicalEditor(),
|
editor: lexicalEditor(),
|
||||||
collections: [
|
collections: [
|
||||||
{
|
{
|
||||||
slug: "pages",
|
slug: 'pages',
|
||||||
admin: {
|
admin: {
|
||||||
useAsTitle: "title",
|
useAsTitle: 'title',
|
||||||
},
|
},
|
||||||
fields: [
|
fields: [
|
||||||
{
|
{
|
||||||
name: "title",
|
name: 'title',
|
||||||
type: "text",
|
type: 'text',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "content",
|
name: 'content',
|
||||||
type: "richText",
|
type: 'richText',
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
slug: "media",
|
slug: 'media',
|
||||||
upload: true,
|
upload: true,
|
||||||
fields: [
|
fields: [
|
||||||
{
|
{
|
||||||
name: "text",
|
name: 'text',
|
||||||
type: "text",
|
type: 'text',
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
secret: process.env.PAYLOAD_SECRET || "",
|
secret: process.env.PAYLOAD_SECRET || '',
|
||||||
typescript: {
|
typescript: {
|
||||||
outputFile: path.resolve(dirname, "payload-types.ts"),
|
outputFile: path.resolve(dirname, 'payload-types.ts'),
|
||||||
},
|
},
|
||||||
// db: postgresAdapter({
|
// db: postgresAdapter({
|
||||||
// pool: {
|
// pool: {
|
||||||
@ -68,29 +68,29 @@ export default buildConfig({
|
|||||||
// }
|
// }
|
||||||
// }),
|
// }),
|
||||||
db: mongooseAdapter({
|
db: mongooseAdapter({
|
||||||
url: process.env.MONGODB_URI || "",
|
url: process.env.MONGODB_URI || '',
|
||||||
}),
|
}),
|
||||||
admin: {
|
admin: {
|
||||||
autoLogin: {
|
autoLogin: {
|
||||||
email: "dev@payloadcms.com",
|
email: 'dev@payloadcms.com',
|
||||||
password: "test",
|
password: 'test',
|
||||||
prefillOnly: true,
|
prefillOnly: true,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
async onInit(payload) {
|
async onInit(payload) {
|
||||||
const existingUsers = await payload.find({
|
const existingUsers = await payload.find({
|
||||||
collection: "users",
|
collection: 'users',
|
||||||
limit: 1,
|
limit: 1,
|
||||||
});
|
})
|
||||||
|
|
||||||
if (existingUsers.docs.length === 0) {
|
if (existingUsers.docs.length === 0) {
|
||||||
await payload.create({
|
await payload.create({
|
||||||
collection: "users",
|
collection: 'users',
|
||||||
data: {
|
data: {
|
||||||
email: "dev@payloadcms.com",
|
email: 'dev@payloadcms.com',
|
||||||
password: "test",
|
password: 'test',
|
||||||
},
|
},
|
||||||
});
|
})
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
// Sharp is now an optional dependency -
|
// Sharp is now an optional dependency -
|
||||||
@ -100,4 +100,4 @@ export default buildConfig({
|
|||||||
// This is temporary - we may make an adapter pattern
|
// This is temporary - we may make an adapter pattern
|
||||||
// for this before reaching 3.0 stable
|
// for this before reaching 3.0 stable
|
||||||
sharp,
|
sharp,
|
||||||
});
|
})
|
||||||
|
@ -36,8 +36,7 @@ const Page = () => {
|
|||||||
contains an example of a custom route running the Local API.
|
contains an example of a custom route running the Local API.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
{/* Commented out for now due to bug */}
|
<Example />
|
||||||
{/* <Example /> */}
|
|
||||||
|
|
||||||
<p>You can use the Local API in your server components like this:</p>
|
<p>You can use the Local API in your server components like this:</p>
|
||||||
<pre>
|
<pre>
|
||||||
|
@ -4,7 +4,7 @@ import configPromise from '@payload-config'
|
|||||||
|
|
||||||
const Example: React.FC = async () => {
|
const Example: React.FC = async () => {
|
||||||
const payload = await getPayload({ config: configPromise })
|
const payload = await getPayload({ config: configPromise })
|
||||||
const url = payload.config.serverURL
|
const url = payload.getAdminURL()
|
||||||
return <div>The admin panel is running at: {url}</div>
|
return <div>The admin panel is running at: {url}</div>
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user