Skip to content

Commit

Permalink
Merge pull request #174 from mobeigi/split-postgres-connection-string…
Browse files Browse the repository at this point in the history
…-envs

Split postgres connection string envs
  • Loading branch information
mobeigi authored Oct 10, 2024
2 parents 37c12ca + 33db928 commit 1a06994
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
7 changes: 6 additions & 1 deletion app/.env.local.example
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,12 @@ SMTP_USER="user"
SMTP_PASS="password"

# Payload
PAYLOAD_DATABASE_URI="postgres://postgres:<password>@127.0.0.1:5432/<database_name>"
PAYLOAD_DATABASE_HOST=localhost
PAYLOAD_DATABASE_PORT=5432
PAYLOAD_DATABASE_USER=postgres
PAYLOAD_DATABASE_PASS=password
PAYLOAD_DATABASE_DATABASE_NAME=db-name

PAYLOAD_SECRET="YOUR_SECRET_HERE"

PAYLOAD_SYSTEM_USER_API_KEY="example"
Expand Down
6 changes: 5 additions & 1 deletion app/src/payload.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,11 @@ export default buildConfig({
db: postgresAdapter({
migrationDir: './src/payload/migrations',
pool: {
connectionString: requireEnvVar(process.env.PAYLOAD_DATABASE_URI, 'PAYLOAD_DATABASE_URI'),
host: requireEnvVar(process.env.PAYLOAD_DATABASE_HOST, 'PAYLOAD_DATABASE_HOST'),
port: Number(requireEnvVar(process.env.PAYLOAD_DATABASE_PORT, 'PAYLOAD_DATABASE_PORT')),
user: requireEnvVar(process.env.PAYLOAD_DATABASE_USER, 'PAYLOAD_DATABASE_USER'),
password: requireEnvVar(process.env.PAYLOAD_DATABASE_PASS, 'PAYLOAD_DATABASE_PASS'),
database: requireEnvVar(process.env.PAYLOAD_DATABASE_DATABASE_NAME, 'PAYLOAD_DATABASE_DATABASE_NAME'),
},
}),
editor: lexicalEditor({
Expand Down

0 comments on commit 1a06994

Please sign in to comment.