80 lines
2.2 KiB
TypeScript
80 lines
2.2 KiB
TypeScript
import { s3Storage } from '@payloadcms/storage-s3'
|
|
import { sqliteAdapter } from '@payloadcms/db-sqlite'
|
|
import { postgresAdapter } from '@payloadcms/db-postgres'
|
|
import { lexicalEditor } from '@payloadcms/richtext-lexical'
|
|
import path from 'path'
|
|
import { buildConfig } from 'payload'
|
|
import { fileURLToPath } from 'url'
|
|
import sharp from 'sharp'
|
|
|
|
import { Users } from './collections/Users'
|
|
import { Media } from './collections/Media'
|
|
import { News } from './collections/News'
|
|
|
|
const filename = fileURLToPath(import.meta.url)
|
|
const dirname = path.dirname(filename)
|
|
|
|
export default buildConfig({
|
|
admin: {
|
|
user: Users.slug,
|
|
importMap: {
|
|
baseDir: path.resolve(dirname),
|
|
},
|
|
},
|
|
collections: [Users, Media, News],
|
|
editor: lexicalEditor(),
|
|
secret: process.env.PAYLOAD_SECRET || '',
|
|
typescript: {
|
|
outputFile: path.resolve(dirname, 'payload-types.ts'),
|
|
},
|
|
// db: sqliteAdapter({
|
|
// client: {
|
|
// url: process.env.DATABASE_URL || '',
|
|
// },
|
|
// }),
|
|
db: postgresAdapter({
|
|
// Postgres-specific arguments go here.
|
|
// `pool` is required.
|
|
pool: {
|
|
connectionString: process.env.DATABASE_URL,
|
|
},
|
|
}),
|
|
sharp,
|
|
plugins: [
|
|
s3Storage({
|
|
enabled: Boolean(process.env.R2_BUCKET),
|
|
collections: {
|
|
media: {
|
|
disablePayloadAccessControl: true,
|
|
generateFileURL: ({ filename, prefix }) => {
|
|
const key = prefix ? `${prefix}/${filename}` : filename
|
|
return `${process.env.R2_PUBLIC_URL}/${key}`
|
|
},
|
|
},
|
|
news: {
|
|
disablePayloadAccessControl: true,
|
|
generateFileURL: ({ filename, prefix }) => {
|
|
const key = prefix ? `${prefix}/${filename}` : filename
|
|
return `${process.env.R2_PUBLIC_URL}/${key}`
|
|
},
|
|
},
|
|
},
|
|
bucket: process.env.R2_BUCKET,
|
|
config: {
|
|
credentials: {
|
|
accessKeyId: process.env.R2_ACCESS_KEY_ID,
|
|
secretAccessKey: process.env.R2_SECRET_ACCESS_KEY,
|
|
},
|
|
region: 'auto',
|
|
// R2 S3 API endpoint — for uploads only, not for serving files
|
|
endpoint: process.env.R2_ENDPOINT,
|
|
forcePathStyle: true,
|
|
},
|
|
}),
|
|
],
|
|
localization: {
|
|
locales: ['es','en','fr','pt'],
|
|
defaultLocale: 'es'
|
|
}
|
|
})
|