Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

hapi-pg-pool

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

hapi-pg-pool

Expose postgres connection pooling to request handlers.

  • 1.0.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
3
Maintainers
1
Weekly downloads
 
Created
Source

Hapi PG Pool Build Status npm Dependency Status

Create a PostgreSQL connection pool available to Hapi request handlers.
Implements pooling with the pg-pool package.

Using

  1. Install from NPM

    npm i hapi-pg-pool -S
    
  2. Ensure you have either your favourite PostgreSQL client dependency, or install the pg client

    npm i pg -S
    
  3. Register the extension

    server.register({
      register: require('hapi-pg-pool'),
      options: {
        database: 'postgres',
        user: 'postgres',
        password: 'postgres'
      }
    }, function (err) {
      if (err) {
        throw err
      }
    
      // server.route(...)
    })
    
  4. Use the pool in your handlers

    server.route({
      method: 'GET',
      path: '/',
      handler: function(request, reply) {
        console.log('sleepy...');
    
        request.pg.query('SELECT pg_sleep(1)', function (err, result) {
          if (err) {
            server.log('error', err)
            return reply(err)
          }
          reply('awake!')
        })
    
      }
    });
    

Refer to pg-pool for more ways to use the request.pg (Pool) object.

License

MIT.

Keywords

FAQs

Package last updated on 21 Feb 2017

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc