{"id":13809774,"url":"https://github.com/seamapi/pg-connection-from-env","last_synced_at":"2025-07-28T05:37:49.139Z","repository":{"id":49316728,"uuid":"517272638","full_name":"seamapi/pg-connection-from-env","owner":"seamapi","description":null,"archived":false,"fork":false,"pushed_at":"2024-11-20T13:03:38.000Z","size":186,"stargazers_count":1,"open_issues_count":4,"forks_count":0,"subscribers_count":5,"default_branch":"main","last_synced_at":"2025-01-28T03:13:07.870Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/seamapi.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2022-07-24T08:53:07.000Z","updated_at":"2023-02-11T02:38:56.000Z","dependencies_parsed_at":"2024-01-15T13:34:55.485Z","dependency_job_id":null,"html_url":"https://github.com/seamapi/pg-connection-from-env","commit_stats":{"total_commits":17,"total_committers":4,"mean_commits":4.25,"dds":"0.47058823529411764","last_synced_commit":"32fb40d87e505535106aabc2a87245e44b52e048"},"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/seamapi%2Fpg-connection-from-env","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/seamapi%2Fpg-connection-from-env/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/seamapi%2Fpg-connection-from-env/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/seamapi%2Fpg-connection-from-env/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/seamapi","download_url":"https://codeload.github.com/seamapi/pg-connection-from-env/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":236101944,"owners_count":19095194,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-08-04T02:00:35.858Z","updated_at":"2025-01-28T22:32:09.164Z","avatar_url":"https://github.com/seamapi.png","language":"TypeScript","readme":"# pg-connection-from-env\n\nConvert environment variables into a usable postgres connection object or postgres uri\n\n## Installation\n\n`yarn add pg-connection-from-env`\n\n## Usage\n\n```ts\nimport getPgConnectionFromEnv, {\n  getConnectionStringFromEnv,\n} from \"pg-connection-from-env\"\n\ngetPgConnectionFromEnv()\n// {\n//   host: 'localhost',\n//   user: 'postgres',\n//   port: 5432,\n//   password: '',\n//   database: 'postgres',\n//   ssl: false\n// }\n\ngetPgConnectionFromEnv({\n  fallbackDefaults: {\n    user: \"userifenvdoesntprovide\",\n    database: \"databaseifenvdoesntprovide\",\n  },\n})\n// {\n//  host: 'localhost',\n//  user: 'userifenvdoesntprovide',\n//  port: 5432,\n//  password: '',\n//  database: 'databaseifuserdoesntprovide',\n//  ssl: false\n// }\n\ngetConnectionStringFromEnv(/* same args as getPgConnectionFromEnv */)\n// \"postgresql://postgres:@localhost:5432/postgres\"\n```\n\n## Arguments\n\n| Argument           | Description                                                |\n| ------------------ | ---------------------------------------------------------- |\n| `fallbackDefaults` | Defaults if env does not provide host, database, user etc. |\n| `user`             | Override user with this                                    |\n| `database`         | Override env database with this                            |\n| `env`              | Environment object to use instead of process.env           |\n\n## Environment Variables\n\nThe following environment variables are used (basically standard postgres env variables)\n\n| Var Name                                         | Description                     |\n| ------------------------------------------------ | ------------------------------- |\n| POSTGRES_HOST                                    | Postgres Host                   |\n| POSTGRES_PASS, POSTGRES_PASSWORD                 | Postgres Password               |\n| POSTGRES_DATABASE, POSTGRES_DB                   | Postgres Database               |\n| POSTGRES_USER, POSTGRES_USERNAME                 | Postgres User                   |\n| POSTGRES_PORT                                    | Postgres Port                   |\n| POSTGRES_URI, POSTGRES_URL, PG_URI, DATABASE_URL | Postgres URI `postgresql://...` |\n| POSTGRES_SSL                                     | If set, true                    |\n","funding_links":[],"categories":["Official Projects"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fseamapi%2Fpg-connection-from-env","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fseamapi%2Fpg-connection-from-env","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fseamapi%2Fpg-connection-from-env/lists"}