69 lines
2.0 KiB
TypeScript
69 lines
2.0 KiB
TypeScript
import path from 'path';
|
|
import { fileURLToPath } from 'url';
|
|
import { buildConfig } from 'payload';
|
|
import { postgresAdapter } from '@payloadcms/db-postgres';
|
|
import { lexicalEditor } from '@payloadcms/richtext-lexical';
|
|
|
|
import { Users } from './collections/Users';
|
|
import { Media } from './collections/Media';
|
|
import { Articles } from './collections/Articles';
|
|
import { Authors } from './collections/Authors';
|
|
import { Categories } from './collections/Categories';
|
|
import { Tags } from './collections/Tags';
|
|
import { Editions } from './collections/Editions';
|
|
import { Subscribers } from './collections/Subscribers';
|
|
|
|
import { withRevalidate } from './lib/withRevalidate';
|
|
|
|
const filename = fileURLToPath(import.meta.url);
|
|
const dirname = path.dirname(filename);
|
|
|
|
const corsOrigins = (process.env.CORS_ORIGINS || '')
|
|
.split(',')
|
|
.map((s) => s.trim())
|
|
.filter(Boolean);
|
|
|
|
// Wrap each publishing collection so a save fires the Astro rebuild webhook.
|
|
const articles = withRevalidate(Articles);
|
|
const authors = withRevalidate(Authors);
|
|
const categories = withRevalidate(Categories);
|
|
const tags = withRevalidate(Tags);
|
|
const editions = withRevalidate(Editions);
|
|
|
|
export default buildConfig({
|
|
serverURL: process.env.SERVER_URL,
|
|
cors: corsOrigins,
|
|
csrf: corsOrigins,
|
|
admin: {
|
|
user: Users.slug,
|
|
importMap: { baseDir: path.resolve(dirname) },
|
|
meta: {
|
|
titleSuffix: ' · SoftVowels CMS',
|
|
},
|
|
},
|
|
collections: [Users, Media, articles, authors, categories, tags, editions, Subscribers],
|
|
editor: lexicalEditor(),
|
|
secret: process.env.PAYLOAD_SECRET || 'dev-secret-change-me',
|
|
typescript: {
|
|
outputFile: path.resolve(dirname, 'payload-types.ts'),
|
|
},
|
|
db: postgresAdapter({
|
|
pool: {
|
|
connectionString: process.env.DATABASE_URI || '',
|
|
},
|
|
}),
|
|
upload: {
|
|
limits: {
|
|
fileSize: 25_000_000,
|
|
},
|
|
},
|
|
endpoints: [],
|
|
hooks: {
|
|
afterError: [
|
|
async (err) => {
|
|
console.error('[payload] afterError', err.error);
|
|
},
|
|
],
|
|
},
|
|
});
|