npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

hapi-handlers-waterline

v1.0.1

Published

A collection of usefull route handlers to interact with tables in databases for hapijs server

Downloads

6

Readme

Build Status Coverage Status

Hapi handlers waterline

A hapi with that makes a couple of useful handlers available to the server for updating tables in databases using hapi-waterline OCR

Installation

npm install --save hapi-handlers-waterline

Usage

'use strict'

const Hapi = require( 'hapi' );

const server = new Hapi.Server( { port: 3000 } );

server.register( {
    register: require( 'hapi-waterline-handlers' ),
    options: { 
        log: console.error
    }
}).then(()=>{

    server.route([
        {
         method: 'POST',
         path:'/test/create',
         handler: server.methods.handler.create({model:'test'}),
        }
    ])
   
});
  • options Object or list of objects with the following keys
    • log Function to print out error logs

Methods

The handler is attached to hapijs server.methods

handler

handler~create() ⇒

Returns a handler for creating a database entry/entries with data in request.payload where request is a hapijs request object

  • options an object with the following keys.
    • model (string) table to update
    • ext function handler extensions
      • onPreHandler evoked before handler function(request, done) where request is a hapijs request object and done is promise resolve should be called one completion.
      • onPreReply evoked before reply function(request, models, done) where request is a hapijs request object, models is sails create return models object and done is promise resolve should be called one completion. done should be called with preferred reply payload. done should be called with preferred reply payload.

Kind: inner method of handler
Returns: function(request, reply)
Api: public

handler~update() ⇒

Returns a handler for updating a database with data in request.payload where request is a hapijs request object

  • options an object with the following keys.
    • ext function handler extensions
      • onPreHandler evoked before handler function(request, done) where request is a hapijs request object and done is promise resolve should be called one completion.
      • onPreReply evoked before reply function(request, models, done) where request is a hapijs request object, models is sails create return models object and done is promise resolve should be called one completion. done should be called with preferred reply payload. -getCriteria function function(request, done) that calls done waterline criteria used to update models in the database
    • model (string) table to update

Kind: inner method of handler
Returns: function(request, reply)
Api: public

handler~get() ⇒

Returns a handler used to retrieve entry/entries from a database

  • options an object with the following keys.
    • ext function handler extensions
      • onPreHandler evoked before handler function(request, done) where request is a hapijs request object and done is promise resolve should be called one completion.
      • onPreReply evoked before reply function(request, models, done) where request is a hapijs request object, models is sails create return models object and done is promise resolve should be called one completion. done should be called with preferred reply payload. waterline criteria used to get models from the database
    • model (string) table to update

Kind: inner method of handler
Returns: function(request, reply)
Api: public

handler~destroy() ⇒

Delete a database entry/entries

  • options an object with the following keys. -getCriteria function function(request, done) that calls done waterline criteria used to delete models in the database
    • model (string) table to delete entries in

Kind: inner method of handler
Returns: function(request, reply)
Api: public

Test

npm run-script test

Contributing

In lieu of a formal styleguide, take care to maintain the existing coding style. Add unit tests for any new or changed functionality. Lint and test your code.

Release History