Thanks to visit codestin.com
Credit goes to github.com

Skip to content

feat: allows for functional config definitions #12329

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

jmikrut
Copy link
Member

@jmikrut jmikrut commented May 6, 2025

It's common to want to first fetch secrets from a third-party location, or perform some other action before returning your Payload config. You could always do this using a pattern like this:

const fetchAndBuildConfig = async () => {
  const mySecrets = await fetchSecrets()
  
  return buildConfig({
    secret: mySecrets.PAYLOAD_SECRET,
    // etc
  })
}

export default fetchAndBuildConfig()

But this is more verbose than it needs to be. We could simplify and handle that complexity just by allowing the developer to pass an async function to buildConfig itself, like this:

export default buildConfig(async () => {
  const mySecrets = await fetchSecrets()
  
  return {
    secret: mySecrets.PAYLOAD_SECRET,
    // etc
  }
})

This PR makes this simpler pattern possible.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant