Skip to content

liviaerxin/hapi-postgres

Repository files navigation

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

About

Hapi postgres plugin for Hapijs that supports multiple connections, inspired by Marsup/hapi-mongodb

Resources

License

Code of conduct

Stars

Watchers

Forks

Packages

 
 
 

Contributors