JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 9769265
  • Score
    100M100P100Q272382F
  • License BSD-2-Clause

Module for reading .pgpass

Package Exports

  • pgpass

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (pgpass) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

pgpass

Build Status

Install

npm install --save hoegaarden/pgpass

Usage

var pgPass = require('pgpass');

var connInfo = {
  'host' : 'pgserver' ,
  'user' : 'the_user_name' ,
};


// ---- async ----
pgPass(connInfo, function(pass){
  conn_info.password = pass;
  // connect to postgresql server
});

Description

This module tries to read the ~/.pgpass file (or the equivalent for windows systems). If the environment variable PGPASSFILE is set, this file is used instead. If everything goes right, the password from said file is to the callback; if the password cannot be read undefined is passed to the callback.

Cases where undefined is returned:

  • the environment variable PGPASSWORD is set
  • the file cannot be read (wrong permissions, no such file, ...)
  • for non windows systems: the file is write-/readable by the group or by other users
  • there is no matching line for the given connection info

The goal of this package is to get included in the node-postgresql module to get the same behaviour for the javascript client as for the native client.

Tests

There are tests in ./test/; including linting and coverage testing. Running npm test runs:

  • jshint
  • mocha tests
  • jscoverage and mocha -R html-cov

You can see the coverage report in coverage.html.

Development, Patches, Bugs, ...

If you find Bugs or have improvments, please feel free to open a issue on github. If you provide a pull request, I'm more than happy to merge them, just make sure to add tests for your changes.