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

flappy

v1.0.0

Published

Fluent hapi server composer

Downloads

11

Readme

flappy - A tiny fluent server composer for hapi.js.

flappy provides a fluent api based composition of hapi's server.

Example

const flappy = require('flappy')

flappy({ port: 3000 })    // Takes the same args as Hapi.server
  .use(require('blipp'))  // `use` a plugin, same args as server.register
  .use(require('inert'))
  .use(require('vision'), opts)   // Pass plugin options
  .use(require('./my-plugin'), opts2)
  .use(require('./logging-plugin'), env.NODE_ENV === 'production')    // Conditional register
  .start()
  .then(server => console.log(server.info))
  .catch(err => {
    console.error(err)
    process.exit(1)
  })

API

flappy(options) => this

flappy is a is a single function taking the same arguments as Hapi.server.

.use(plugins, [options], [condition = true]) => this

The use method takes the same arguments as hapi's server.register function. See https://hapijs.com/api#server.register()

There is an additional third parameter condition that can be used to conditionally register the plugin. Useful for when you only want to register a plugin in a certain env.

.start() => Promise<Hapi.server>

Registers the plugins and starts the hapi server

.compose() => Promise<Hapi.server>

Registers the plugins, initializes the server without starting it. Use when testing the server.

hapi version dependency

flappy can support different versions of hapi. Adding support for a new version of hapi is considered a minor change. Removing support for a version of hapi is considered a major change.

By default NPM will resolve flappy's dependency on hapi using the most recent supported version of hapi. To force a specific supported hapi version for your project, include hapi in your package dependencies along side of flappy.

Flappy only supports hapi 17+.

Why?

Less code in getting a hapi server up. Arguably more concise. The fluent design encourages server code to always be registered via plugins.

More Examples

// Async / await example
const flappy = require('flappy')

try {
  const server = flappy({ port: 3000 })
    .use(require('blipp'))
    .use(require('inert'))
    .use(require('vision'), opts)
    .use(require('./my-plugin'), opts2)
    .start()

  console.log(server.info)
} catch (err) {
  console.error(err)
  process.exit(1)
}