Repository navigation
Expand file tree
/
Copy pathpayload.config.ts
More file actions
113 lines (108 loc) · 3.5 KB
/
Copy pathpayload.config.ts
File metadata and controls
113 lines (108 loc) · 3.5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
// storage-adapter-import-placeholder
import { mongooseAdapter } from '@payloadcms/db-mongodb'
import sharp from 'sharp' // sharp-import
import path from 'path'
import { buildConfig, PayloadRequest } from 'payload'
import { fileURLToPath } from 'url'
import { multiTenantPlugin } from '@payloadcms/plugin-multi-tenant'
import type { Config } from './payload-types'
import { Amenities } from './collections/Amenities'
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 { Brands } from './collections/Brands'
const filename = fileURLToPath(import.meta.url)
const dirname = path.dirname(filename)
export default buildConfig({
admin: {
components: {
// The `BeforeLogin` component renders a message that you see while logging into your admin panel.
// Feel free to delete this at any time. Simply remove the line below.
beforeLogin: ['@/components/BeforeLogin'],
// The `BeforeDashboard` component renders the 'welcome' block that you see after logging into your admin panel.
// Feel free to delete this at any time. Simply remove the line below.
beforeDashboard: ['@/components/BeforeDashboard', '@/components/SeedButton'],
},
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,
},
],
},
},
// This config helps us configure global or default features that the other editors can inherit
editor: defaultLexical,
db: mongooseAdapter({
url: process.env.DATABASE_URI || '',
}),
collections: [Pages, Posts, Media, Categories, Users, Brands, Amenities, Header, Footer],
cors: [getServerSideURL()].filter(Boolean),
plugins: [
...plugins,
multiTenantPlugin<Config>({
tenantsSlug: 'brands',
tenantSelectorLabel: 'Brand',
collections: {
pages: {},
posts: {},
header: {
isGlobal: true,
},
footer: {
isGlobal: true,
},
},
userHasAccessToAllTenants: (user) => {
// Check if user has a 'super-admin' role or is an admin
return user?.roles?.includes('super-admin') || false
},
}),
// storage-adapter-placeholder
],
secret: process.env.PAYLOAD_SECRET,
sharp,
typescript: {
outputFile: path.resolve(dirname, 'payload-types.ts'),
},
jobs: {
access: {
run: ({ req }: { req: PayloadRequest }): boolean => {
// Allow logged in users to execute this endpoint (default)
if (req.user) return true
// If there is no logged in user, then check
// for the Vercel Cron secret to be present as an
// Authorization header:
const authHeader = req.headers.get('authorization')
return authHeader === `Bearer ${process.env.CRON_SECRET}`
},
},
tasks: [],
},
})