hapi-postgres

1.0.3 • Public • Published

Hapi-Postgres

This is a plugin to expose a shared PostgreSQL connection pool across the whole Hapi server and each request.

It helps developers to concentrate on query() operation, reducing the burden to control connect() and end() operations before and after each query().

Getting Started

Options

Several objects are exposed by this plugin:

  • client: The single client of postgresql, an instance of pg.Client
  • pool: The connection of pool of postgresql, an instance of pg.Pool
  • lib: node-postgre library

Example

Test

node --watch server.js
node --watch-path=./src server.js
GET http://127.0.0.1:4000 HTTP/1.1
GET http://127.0.0.1:4000/test HTTP/1.1
docker run -it --rm \
    -e POSTGRES_USER=postgres \
    -e POSTGRES_PASSWORD=mysecretpassword \
    -e POSTGRES_DB=db \
    -p 5432:5432 \
    postgres

Compatibility level

Ships with mongodb 3.x.

References

Readme

Keywords

Package Sidebar

Install

npm i hapi-postgres

Weekly Downloads

2

Version

1.0.3

License

MIT

Unpacked Size

31.1 kB

Total Files

11

Last publish

Collaborators

  • liviaerxin