Problem
Both example applications hardcode Postgres connection details in index.ts:
const postgresConfig = {
host: "localhost",
port: 5432,
user: "postgres",
password: "postgres",
database: "dcb_test_1"
}
This doesn't work out of the box for anyone with a different local setup and is a bad pattern to model in example code.
Fix
- Read connection details from environment variables (or a
DATABASE_URL connection string)
- Add a
.env.example file to each example with documented defaults
- Add
.env to .gitignore
- Update the example README (or root README) to explain how to configure the examples
Problem
Both example applications hardcode Postgres connection details in
index.ts:This doesn't work out of the box for anyone with a different local setup and is a bad pattern to model in example code.
Fix
DATABASE_URLconnection string).env.examplefile to each example with documented defaults.envto.gitignore