-
Notifications
You must be signed in to change notification settings - Fork 0
/
payload.config.ts
77 lines (71 loc) · 2.19 KB
/
payload.config.ts
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
import path from 'node:path'
import { postgresAdapter } from '@payloadcms/db-postgres'
import { en } from 'payload/i18n/en'
import { lexicalEditor } from '@payloadcms/richtext-lexical'
import { buildConfig } from 'payload'
import sharp from 'sharp'
import { fileURLToPath } from 'node:url'
import { MoviesCollection } from '@/cms/collections/movie'
import { MediaCollection } from '@/cms/collections/media'
import { UsersCollection } from '@/cms/collections/users'
import { vercelBlobStorage } from '@payloadcms/storage-vercel-blob'
const filename = fileURLToPath(import.meta.url)
const dirname = path.dirname(filename)
export default buildConfig({
editor: lexicalEditor(),
collections: [UsersCollection, MoviesCollection, MediaCollection],
secret: process.env.PAYLOAD_SECRET || '',
typescript: {
outputFile: path.resolve(dirname, 'payload-types.ts'),
},
db: postgresAdapter({
pool: {
connectionString: process.env.POSTGRES_URL || '',
},
}),
plugins: process.env.BLOB_READ_WRITE_TOKEN
? [
vercelBlobStorage({
collections: {
[MediaCollection.slug]: true,
},
token: process.env.BLOB_READ_WRITE_TOKEN || '',
}),
]
: [],
/**
* Payload can now accept specific translations from 'payload/i18n/en'
* This is completely optional and will default to English if not provided
*/
i18n: {
supportedLanguages: { en },
},
admin: {
// autoLogin: {
// email: '[email protected]',
// password: 'test',
// prefillOnly: true,
// },
},
async onInit(payload) {
const existingUsers = await payload.find({
collection: 'users',
limit: 1,
})
if (existingUsers.docs.length === 0) {
await payload.create({
collection: 'users',
data: {
email: process.env.ADMIN_USER || '[email protected]',
password: process.env.ADMIN_PASSWORD || 'test',
},
})
}
},
// Sharp is now an optional dependency -
// if you want to resize images, crop, set focal point, etc.
// make sure to install it and pass it to the config.
// This is temporary - we may make an adapter pattern
// for this before reaching 3.0 stable
sharp,
})