Skip to content

Commit ecbafbf

Browse files
committed
fix(templates): remove req from seed script
1 parent 7314990 commit ecbafbf

File tree

2 files changed

+2
-100
lines changed
  • templates
    • website/src/endpoints/seed
    • with-vercel-website/src/endpoints/seed

2 files changed

+2
-100
lines changed

templates/website/src/endpoints/seed/index.ts

Lines changed: 1 addition & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,6 @@ export const seed = async ({
4848
data: {
4949
navItems: [],
5050
},
51-
req,
5251
})
5352
}
5453

@@ -60,18 +59,14 @@ export const seed = async ({
6059
exists: true,
6160
},
6261
},
63-
req,
6462
})
6563
}
6664

6765
const pages = await payload.delete({
6866
collection: 'pages',
6967
where: {},
70-
req,
7168
})
7269

73-
console.log({ pages })
74-
7570
payload.logger.info(`— Seeding demo author and user...`)
7671

7772
await payload.delete({
@@ -81,7 +76,6 @@ export const seed = async ({
8176
equals: 'demo-author@payloadcms.com',
8277
},
8378
},
84-
req,
8579
})
8680

8781
const demoAuthor = await payload.create({
@@ -91,7 +85,6 @@ export const seed = async ({
9185
email: 'demo-author@payloadcms.com',
9286
password: 'password',
9387
},
94-
req,
9588
})
9689

9790
let demoAuthorID: number | string = demoAuthor.id
@@ -111,34 +104,11 @@ export const seed = async ({
111104
'https://raw.githubusercontent.com/payloadcms/payload/refs/heads/main/templates/website/src/endpoints/seed/image-hero1.webp',
112105
),
113106
])
114-
// Log all but not the buffer
115-
req.payload.logger.info({
116-
image1Buffer: {
117-
name: image1Buffer.name,
118-
mimetype: image1Buffer.mimetype,
119-
size: image1Buffer.size,
120-
},
121-
image2Buffer: {
122-
name: image2Buffer.name,
123-
mimetype: image2Buffer.mimetype,
124-
size: image2Buffer.size,
125-
},
126-
image3Buffer: {
127-
name: image3Buffer.name,
128-
mimetype: image3Buffer.mimetype,
129-
size: image3Buffer.size,
130-
},
131-
hero1Buffer: {
132-
name: hero1Buffer.name,
133-
mimetype: hero1Buffer.mimetype,
134-
size: hero1Buffer.size,
135-
},
136-
})
107+
137108
const image1Doc = await payload.create({
138109
collection: 'media',
139110
data: image1,
140111
file: image1Buffer,
141-
req,
142112
})
143113
const image2Doc = await payload.create({
144114
collection: 'media',
@@ -150,13 +120,11 @@ export const seed = async ({
150120
collection: 'media',
151121
data: image2,
152122
file: image3Buffer,
153-
req,
154123
})
155124
const imageHomeDoc = await payload.create({
156125
collection: 'media',
157126
data: image2,
158127
file: hero1Buffer,
159-
req,
160128
})
161129

162130
payload.logger.info(`— Seeding categories...`)
@@ -165,47 +133,41 @@ export const seed = async ({
165133
data: {
166134
title: 'Technology',
167135
},
168-
req,
169136
})
170137

171138
const newsCategory = await payload.create({
172139
collection: 'categories',
173140
data: {
174141
title: 'News',
175142
},
176-
req,
177143
})
178144

179145
const financeCategory = await payload.create({
180146
collection: 'categories',
181147
data: {
182148
title: 'Finance',
183149
},
184-
req,
185150
})
186151

187152
await payload.create({
188153
collection: 'categories',
189154
data: {
190155
title: 'Design',
191156
},
192-
req,
193157
})
194158

195159
await payload.create({
196160
collection: 'categories',
197161
data: {
198162
title: 'Software',
199163
},
200-
req,
201164
})
202165

203166
await payload.create({
204167
collection: 'categories',
205168
data: {
206169
title: 'Engineering',
207170
},
208-
req,
209171
})
210172

211173
let image1ID: number | string = image1Doc.id
@@ -233,7 +195,6 @@ export const seed = async ({
233195
.replace(/"\{\{IMAGE_2\}\}"/g, String(image2ID))
234196
.replace(/"\{\{AUTHOR\}\}"/g, String(demoAuthorID)),
235197
),
236-
req,
237198
})
238199

239200
const post2Doc = await payload.create({
@@ -244,7 +205,6 @@ export const seed = async ({
244205
.replace(/"\{\{IMAGE_2\}\}"/g, String(image3ID))
245206
.replace(/"\{\{AUTHOR\}\}"/g, String(demoAuthorID)),
246207
),
247-
req,
248208
})
249209

250210
const post3Doc = await payload.create({
@@ -255,7 +215,6 @@ export const seed = async ({
255215
.replace(/"\{\{IMAGE_2\}\}"/g, String(image1ID))
256216
.replace(/"\{\{AUTHOR\}\}"/g, String(demoAuthorID)),
257217
),
258-
req,
259218
})
260219

261220
// update each post with related posts
@@ -265,23 +224,20 @@ export const seed = async ({
265224
data: {
266225
relatedPosts: [post2Doc.id, post3Doc.id],
267226
},
268-
req,
269227
})
270228
await payload.update({
271229
id: post2Doc.id,
272230
collection: 'posts',
273231
data: {
274232
relatedPosts: [post1Doc.id, post3Doc.id],
275233
},
276-
req,
277234
})
278235
await payload.update({
279236
id: post3Doc.id,
280237
collection: 'posts',
281238
data: {
282239
relatedPosts: [post1Doc.id, post2Doc.id],
283240
},
284-
req,
285241
})
286242

287243
payload.logger.info(`— Seeding home page...`)
@@ -293,15 +249,13 @@ export const seed = async ({
293249
.replace(/"\{\{IMAGE_1\}\}"/g, String(imageHomeID))
294250
.replace(/"\{\{IMAGE_2\}\}"/g, String(image2ID)),
295251
),
296-
req,
297252
})
298253

299254
payload.logger.info(`— Seeding contact form...`)
300255

301256
const contactForm = await payload.create({
302257
collection: 'forms',
303258
data: JSON.parse(JSON.stringify(contactFormData)),
304-
req,
305259
})
306260

307261
let contactFormID: number | string = contactForm.id
@@ -317,7 +271,6 @@ export const seed = async ({
317271
data: JSON.parse(
318272
JSON.stringify(contactPageData).replace(/"\{\{CONTACT_FORM_ID\}\}"/g, String(contactFormID)),
319273
),
320-
req,
321274
})
322275

323276
payload.logger.info(`— Seeding header...`)
@@ -345,7 +298,6 @@ export const seed = async ({
345298
},
346299
],
347300
},
348-
req,
349301
})
350302

351303
payload.logger.info(`— Seeding footer...`)
@@ -379,7 +331,6 @@ export const seed = async ({
379331
},
380332
],
381333
},
382-
req,
383334
})
384335

385336
payload.logger.info('Seeded database successfully!')

0 commit comments

Comments
 (0)