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 🙏

© 2025 – Pkg Stats / Ryan Hefner

propathink

v0.0.23

Published

rethinkdb client modular request builder

Downloads

45

Readme

propathink

Build Status

rethinkdb client

rethinkdb client focused on maintainable code organization. Store rethinkdb request logic in modular way by labelling and storing requests in plugins/modules. In theory, propathink's architecture is extendable allowing you to add plugins at will in order to better maintain and manage all db request logic.

configuration centric plugin design

propathink utilizes a manifest file for each project. The manifest configures the database connection and all request plugins to be loaded in a project. Those familiar with hapijs/glue will be comfortable with this design.

provisions rethink connection

Every request built using a propathink plugin is provisioned with the propathink object this and pthinkInternals object. See below for example showing how to use these objects to make a db request. Note: every rethinkdb connection is stored in the this.conn. And, pthinkInternals.db contains the configured database name declared in the manifest.

pthinkInternals.db      // configured database name from the manifest file.
this.conn               // generated rethinkdb connection object

Sample rethinkdb request made below:

return Rethinkdb.dbCreate(pthinkInternals.db).run(this.conn, (err, result) => {

    ....... code handling results .......
});

joi validation

propathink imitates hapi's use of joi to validate parameters set in a request. Sample request below:

{
    name: 'testTwo',
    comment: 'testTwo documentation here.',
    validate: {
        0: { // parameter at arguments[0] to be validated.
            username: Joi.string().min(3).max(6),
            password: Joi.string().min(3).max(8)
        }
    },
    handler: function (user, next, callback) {

             return callback(null, 'test two result', next);
    }
}

Note: The object key determines which parameter will be evaluated by joi in the request. The above valdation configuration applies the joi test to the first parameter in the handler.

request lifecycle

propathink again imitates hapijs by utilizing a request lifecyle for all request logic. The lifecyle has four steps: pre, validate, request, after.

  • pre generates the connection for the request.
  • validate applies joi validations to appropriate parameters in requests.
  • request executes the request built in the handle.
  • after runs after everything else is completed.

constructing the handle

The handle element in a propathink request object must have the last two parameters in order for the request lifecycle to work (next & callback): next is executed at the end of each step in the life cycle and needs to be passed to the callback in the handle. It must be executed in the callback your write to be consumed in the handler. This ensures the after step of the lifecyle is really executed "after" the request is completed. If this is not done correctly, the after step in the lifecyce will execute before your database read and writes are completed. Plus, executing next this way allows for monitoring performance and quantity of code execution.

database request monitoring

Excitingly, utilizing the request lifecyle design to construct database requests allows for monitoring of all requests' performance and usage.

influence of hapijs design

propathink is highly influenced by hapijs architecture. After studying hapi's architecture decided to build propathink using a plugin architecture in order to better maintain database request logic and all the other good stuff propathink does.

Test

project requires 100% test coverage. hapijs/lab testing framework and hapijs/code assertian library. Travis is used to enfore and prove 100% test coverage exists in github repo.

Style Guide

Project abides by the hapijs style guide. Style guide is enforced using hapijs/lab testing framework and The framework's linting standards enforce style guide. Travis will fail is linting tests do not pass.