-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpayload.config.ts
153 lines (146 loc) · 3.45 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
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
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
import path from 'path'
// import { postgresAdapter } from '@payloadcms/db-postgres'
import { en } from 'payload/i18n/en'
import {
AlignFeature,
BlockquoteFeature,
BlocksFeature,
BoldFeature,
ChecklistFeature,
HeadingFeature,
IndentFeature,
InlineCodeFeature,
ItalicFeature,
lexicalEditor,
LinkFeature,
OrderedListFeature,
ParagraphFeature,
RelationshipFeature,
UnorderedListFeature,
UploadFeature,
} from '@payloadcms/richtext-lexical'
// import { mongooseAdapter } from '@payloadcms/db-mongodb'
import { postgresAdapter } from '@payloadcms/db-postgres'
import { buildConfig } from 'payload'
import FormBuilder from '@payloadcms/plugin-form-builder'
import { nodemailerAdapter } from '@payloadcms/email-nodemailer'
import sharp from 'sharp'
import { fileURLToPath } from 'url'
const filename = fileURLToPath(import.meta.url)
const dirname = path.dirname(filename)
console.log(typeof FormBuilder) // Check if it's a function or something else
export default buildConfig({
email: nodemailerAdapter({
defaultFromName: 'Dott.ssa Iolanda Grasso',
defaultFromAddress: 'admin@example.com',
transportOptions: {
service: 'gmail',
auth: {
user: process.env.GMAIL_USER,
pass: process.env.GMAIL_PASS,
},
},
}),
//editor: slateEditor({}),
editor: lexicalEditor(),
collections: [
{
slug: 'users',
auth: true,
access: {
delete: () => false,
update: () => false,
},
fields: [],
},
{
slug: 'pages',
admin: {
useAsTitle: 'title',
},
fields: [
{
name: 'title',
type: 'text',
},
{
name: 'content',
type: 'richText',
},
],
},
{
slug: 'media',
upload: true,
fields: [
{
name: 'text',
type: 'text',
},
],
},
],
secret: process.env.PAYLOAD_SECRET || '',
typescript: {
outputFile: path.resolve(dirname, 'payload-types.ts'),
},
db: postgresAdapter({
pool: {
connectionString: process.env.DATABASE_URI || '',
},
}),
// db: mongooseAdapter({
// url: process.env.MONGODB_URI || '',
// }),
/**
* 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: 'wonderkido66@gmail.com',
password: 'test',
prefillOnly: true,
},
},
// plugins: [
// FormBuilder({
// fields: {
// text: true,
// textarea: false,
// select: false,
// email: true,
// state: false,
// country: false,
// checkbox: true,
// number: true,
// message: true,
// payment: false,
// },
// }),
// ],
async onInit(payload) {
const existingUsers = await payload.find({
collection: 'users',
limit: 1,
})
if (existingUsers.docs.length === 0) {
await payload.create({
collection: 'users',
data: {
email: 'dev@payloadcms.com',
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,
})