postgresql-socket-url

1.0.1 • Public • Published

postgresql-socket-url

Generates a well-formed URL for a given PostgreSQL domain socket path and database name. Useful when you want to use a database driver (like pg) to connect to PostgreSQL through a Unix domain socket.

Example

"use strict";

const postgresqlSocketUrl = require("postgresql-socket-url");

let url = postgresqlSocketUrl({
	socketPath: "/tmp",
	database: "myproject"
});

console.log(url); // socket:/tmp?db=myproject

API

postgresqlSocketUrl(options)

Generates the URL to connect to.

  • options:
    • socketPath: The path of the folder that contains the PostgreSQL socket. Not the path of the socket itself.
    • database: The name of the database to connect to.

Changelog

1.0.1 (September 14, 2019)

  • Fixes validation logic to actually throw when the options are missing.

1.0.0 (September 14, 2019)

Initial release.

Dependencies (1)

Dev Dependencies (0)

    Package Sidebar

    Install

    npm i postgresql-socket-url

    Weekly Downloads

    2

    Version

    1.0.1

    License

    WTFPL OR CC0-1.0

    Unpacked Size

    3.15 kB

    Total Files

    5

    Last publish

    Collaborators

    • joepie91