120 lines
3.0 KiB
TypeScript
120 lines
3.0 KiB
TypeScript
import { postgresAdapter } from '@payloadcms/db-postgres'
|
|
import sharp from 'sharp'
|
|
import path from 'path'
|
|
import { buildConfig, PayloadRequest } from 'payload'
|
|
import { fileURLToPath } from 'url'
|
|
|
|
import { Categories } from './collections/Categories'
|
|
import { Media } from './collections/Media'
|
|
import { Pages } from './collections/Pages'
|
|
import { Posts } from './collections/Posts'
|
|
import { Users } from './collections/Users'
|
|
import { Footer } from './Footer/config'
|
|
import { Header } from './Header/config'
|
|
import { plugins } from './plugins'
|
|
import { defaultLexical } from '@/fields/defaultLexical'
|
|
import { getServerSideURL } from './utilities/getURL'
|
|
import { AnnouncementBar } from '@/globals/AnnouncementBar'
|
|
import { PopupAnnouncement } from '@/globals/PopupAnnouncement/config'
|
|
import { SiteSettings } from '@/globals/SiteSettings'
|
|
import { nodemailerAdapter } from '@payloadcms/email-nodemailer'
|
|
|
|
const filename = fileURLToPath(import.meta.url)
|
|
const dirname = path.dirname(filename)
|
|
|
|
export default buildConfig({
|
|
admin: {
|
|
avatar: {
|
|
Component: '@/components/AdminIcon',
|
|
},
|
|
components: {
|
|
graphics: {
|
|
Logo: '@/components/AdminLogo',
|
|
Icon: '@/components/AdminIcon',
|
|
},
|
|
beforeLogin: ['@/components/BeforeLogin'],
|
|
beforeDashboard: ['@/components/BeforeDashboard'],
|
|
},
|
|
importMap: {
|
|
baseDir: path.resolve(dirname),
|
|
},
|
|
user: Users.slug,
|
|
livePreview: {
|
|
breakpoints: [
|
|
{
|
|
label: 'Mobile',
|
|
name: 'mobile',
|
|
width: 375,
|
|
height: 667,
|
|
},
|
|
{
|
|
label: 'Tablet',
|
|
name: 'tablet',
|
|
width: 768,
|
|
height: 1024,
|
|
},
|
|
{
|
|
label: 'Desktop',
|
|
name: 'desktop',
|
|
width: 1440,
|
|
height: 900,
|
|
},
|
|
],
|
|
},
|
|
},
|
|
editor: defaultLexical,
|
|
db: postgresAdapter({
|
|
pool: {
|
|
connectionString: process.env.DATABASE_URL,
|
|
max: 3,
|
|
},
|
|
}),
|
|
collections: [Pages, Posts, Media, Categories, Users],
|
|
cors: [getServerSideURL()].filter(Boolean),
|
|
globals: [Header, Footer, AnnouncementBar, PopupAnnouncement, SiteSettings],
|
|
plugins,
|
|
...(process.env.SMTP_HOST ? {
|
|
email: nodemailerAdapter({
|
|
defaultFromAddress: 'no-reply@fiberdirekt.se',
|
|
defaultFromName: 'Fiber Direkt',
|
|
transportOptions: {
|
|
host: process.env.SMTP_HOST,
|
|
port: Number(process.env.SMTP_PORT) || 587,
|
|
auth: {
|
|
user: process.env.SMTP_USER,
|
|
pass: process.env.SMTP_PASS,
|
|
},
|
|
},
|
|
}),
|
|
} : {}),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
secret: process.env.PAYLOAD_SECRET,
|
|
sharp,
|
|
typescript: {
|
|
outputFile: path.resolve(dirname, 'payload-types.ts'),
|
|
},
|
|
jobs: {
|
|
access: {
|
|
run: ({ req }: { req: PayloadRequest }): boolean => {
|
|
if (req.user) return true
|
|
const secret = process.env.CRON_SECRET
|
|
if (!secret) return false
|
|
const authHeader = req.headers.get('authorization')
|
|
return authHeader === `Bearer ${secret}`
|
|
},
|
|
},
|
|
tasks: [],
|
|
},
|
|
})
|