chore: properly isolates req in parallel requests
This commit is contained in:
@@ -31,7 +31,7 @@ import { GlobalGroup1A } from './globals/Group1A.js'
|
||||
import { GlobalGroup1B } from './globals/Group1B.js'
|
||||
import { GlobalHidden } from './globals/Hidden.js'
|
||||
import { GlobalNoApiView } from './globals/NoApiView.js'
|
||||
import { clearAndSeedEverything } from './seed.js'
|
||||
import { seed } from './seed.js'
|
||||
import { customNestedViewPath, customParamViewPath, customViewPath } from './shared.js'
|
||||
|
||||
export default buildConfigWithDefaults({
|
||||
@@ -129,7 +129,7 @@ export default buildConfigWithDefaults({
|
||||
},
|
||||
onInit: async (payload) => {
|
||||
if (process.env.SEED_IN_CONFIG_ONINIT !== 'false') {
|
||||
await clearAndSeedEverything(payload)
|
||||
await seed(payload)
|
||||
}
|
||||
},
|
||||
})
|
||||
|
||||
@@ -14,102 +14,104 @@ import {
|
||||
usersCollectionSlug,
|
||||
} from './slugs.js'
|
||||
|
||||
export async function clearAndSeedEverything(_payload: Payload, parallel: boolean = false) {
|
||||
export const seed = async (_payload) => {
|
||||
await executePromises(
|
||||
[
|
||||
() =>
|
||||
_payload.create({
|
||||
collection: usersCollectionSlug,
|
||||
data: {
|
||||
email: devUser.email,
|
||||
password: devUser.password,
|
||||
},
|
||||
depth: 0,
|
||||
overrideAccess: true,
|
||||
}),
|
||||
...[...Array(11)].map(
|
||||
() => () =>
|
||||
_payload.create({
|
||||
collection: postsCollectionSlug,
|
||||
data: {
|
||||
title: 'Title',
|
||||
description: 'Description',
|
||||
},
|
||||
depth: 0,
|
||||
overrideAccess: true,
|
||||
}),
|
||||
),
|
||||
() =>
|
||||
_payload.create({
|
||||
collection: customViews1CollectionSlug,
|
||||
data: {
|
||||
title: 'Custom View',
|
||||
},
|
||||
depth: 0,
|
||||
overrideAccess: true,
|
||||
}),
|
||||
() =>
|
||||
_payload.create({
|
||||
collection: customViews2CollectionSlug,
|
||||
data: {
|
||||
title: 'Custom View',
|
||||
},
|
||||
depth: 0,
|
||||
overrideAccess: true,
|
||||
}),
|
||||
() =>
|
||||
_payload.create({
|
||||
collection: geoCollectionSlug,
|
||||
data: {
|
||||
point: [7, -7],
|
||||
},
|
||||
depth: 0,
|
||||
overrideAccess: true,
|
||||
}),
|
||||
() =>
|
||||
_payload.create({
|
||||
collection: geoCollectionSlug,
|
||||
data: {
|
||||
point: [5, -5],
|
||||
},
|
||||
depth: 0,
|
||||
overrideAccess: true,
|
||||
}),
|
||||
() =>
|
||||
_payload.create({
|
||||
collection: noApiViewCollectionSlug,
|
||||
data: {},
|
||||
depth: 0,
|
||||
overrideAccess: true,
|
||||
}),
|
||||
() =>
|
||||
_payload.create({
|
||||
collection: 'customIdTab',
|
||||
data: {
|
||||
id: customIdCollectionId,
|
||||
title: 'Hello world title',
|
||||
},
|
||||
depth: 0,
|
||||
overrideAccess: true,
|
||||
}),
|
||||
() =>
|
||||
_payload.create({
|
||||
collection: 'customIdRow',
|
||||
data: {
|
||||
id: customIdCollectionId,
|
||||
title: 'Hello world title',
|
||||
},
|
||||
depth: 0,
|
||||
overrideAccess: true,
|
||||
}),
|
||||
],
|
||||
false,
|
||||
)
|
||||
}
|
||||
|
||||
export async function clearAndSeedEverything(_payload: Payload) {
|
||||
return await seedDB({
|
||||
snapshotKey: 'adminTest',
|
||||
collectionSlugs,
|
||||
_payload,
|
||||
seedFunction: async (_payload) => {
|
||||
await executePromises(
|
||||
[
|
||||
() =>
|
||||
_payload.create({
|
||||
collection: usersCollectionSlug,
|
||||
data: {
|
||||
email: devUser.email,
|
||||
password: devUser.password,
|
||||
},
|
||||
depth: 0,
|
||||
overrideAccess: true,
|
||||
}),
|
||||
...[...Array(11)].map(
|
||||
() => () =>
|
||||
_payload.create({
|
||||
collection: postsCollectionSlug,
|
||||
data: {
|
||||
title: 'Title',
|
||||
description: 'Description',
|
||||
},
|
||||
depth: 0,
|
||||
overrideAccess: true,
|
||||
}),
|
||||
),
|
||||
() =>
|
||||
_payload.create({
|
||||
collection: customViews1CollectionSlug,
|
||||
data: {
|
||||
title: 'Custom View',
|
||||
},
|
||||
depth: 0,
|
||||
overrideAccess: true,
|
||||
}),
|
||||
() =>
|
||||
_payload.create({
|
||||
collection: customViews2CollectionSlug,
|
||||
data: {
|
||||
title: 'Custom View',
|
||||
},
|
||||
depth: 0,
|
||||
overrideAccess: true,
|
||||
}),
|
||||
() =>
|
||||
_payload.create({
|
||||
collection: geoCollectionSlug,
|
||||
data: {
|
||||
point: [7, -7],
|
||||
},
|
||||
depth: 0,
|
||||
overrideAccess: true,
|
||||
}),
|
||||
() =>
|
||||
_payload.create({
|
||||
collection: geoCollectionSlug,
|
||||
data: {
|
||||
point: [5, -5],
|
||||
},
|
||||
depth: 0,
|
||||
overrideAccess: true,
|
||||
}),
|
||||
() =>
|
||||
_payload.create({
|
||||
collection: noApiViewCollectionSlug,
|
||||
data: {},
|
||||
depth: 0,
|
||||
overrideAccess: true,
|
||||
}),
|
||||
() =>
|
||||
_payload.create({
|
||||
collection: 'customIdTab',
|
||||
data: {
|
||||
id: customIdCollectionId,
|
||||
title: 'Hello world title',
|
||||
},
|
||||
depth: 0,
|
||||
overrideAccess: true,
|
||||
}),
|
||||
() =>
|
||||
_payload.create({
|
||||
collection: 'customIdRow',
|
||||
data: {
|
||||
id: customIdCollectionId,
|
||||
title: 'Hello world title',
|
||||
},
|
||||
depth: 0,
|
||||
overrideAccess: true,
|
||||
}),
|
||||
],
|
||||
parallel,
|
||||
)
|
||||
},
|
||||
seedFunction: seed,
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user