1.0.4 • Published 1 year ago

pg-json-credentials-to-url v1.0.4

Weekly downloads
-
License
-
Repository
github
Last release
1 year ago

pg-json-credentials-to-url

This package makes it easy to convert from raw JSON Postgres credentials to a Postgres connection URL. The expected JSON format matches the format used in AWS RDS credential secrets.

Install

npm install pg-json-credentials-to-url

Usage

You can use the package directly by importing it.

import { pgJsonCredentialsToUrl } from "pg-json-credentials-to-url";

const DATABASE_URL = pgJsonCredentialsToUrl(
  '{"username":"username","password":"password","host":"host","port":"5432","dbname":"database"}'
);

// Outputs: "postgres://username:password@host:5432/database"
console.log(DATABASE_URL);

Or use it in shell scripts.

export DATABASE_URL="$(pg-json-credentials-to-url $DATABASE_CREDENTIALS)"

npx prisma migrate deploy

API

  • pgJsonCredentialsToUrl(credentials: string | object | undefined): string - Takes your credentials as a JSON string or a pre-parsed object and returns a Postgres URL string. Throws if any errors are encountered parsing the database credentials.

CLI

  • pg-json-credentials-to-url DATABASE_CREDENTIALS_JSON - Takes a single required argument and outputs the URL to stdout.
1.0.4

1 year ago

1.0.3

1 year ago

1.0.2

1 year ago

1.0.1

1 year ago

1.0.0

1 year ago