Skip to content
This repository was archived by the owner on Feb 12, 2022. It is now read-only.

heroku/uku

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

95 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

#uku hero

overview

uku is a hapijs boilerplate generator for slinging together APIs/microservices/what-have-yous. It's not another simple lightweight framework that scales and makes empty promises -- it's just a great practice for working with http in node.js.

As mentioned, it's based on hapijs -- an opensource framework that is maintained by WalmartLabs and used internally to power their node.js efforst (including http://m.walmart.com).

background

This project kicked off with the intent of simply being a boilerplate nodejs server that could be forked-and-customized for each project. These are the primary goals of the project:

  • the ability for uku-derived projects to reap the benefits of improvements to the uku-base project/ecosystem while avoiding merge conflicts
  • enable other teams to implement/test/deploy their project(s) independently of any other teams while leaving it trivial to absorb their work into a primary project (e.g. longboard which is used to provide dashboard-supporting server-side endpoints).
  • highly extensible and reusable but without being excessively-opinionated on what you build and deploy
  • avoid merge-conflicts inherent when working on large projects spanning multiple teams

digging in

It turned out most of our needs are met by the hapijs-ecosystem itself. I initially started building a module that would load plugins and export one server -- only to discover that glue does precisely that. So that's index.js :).

Glue exports a single function compose accepting a JSON manifest file specifying the Hapi server options, connections and plugins. Glue primarily works in synergy with Rejoice, but can be integrated directly into any Hapi application loader.

When you create an uku project, you'll find that it requires the uku module and feeds it a manifest file:

/* some content omitted for brevity */

const manifest = {
  server: {
    load: config.get('/server/load'),
    debug: {
      request: ['error']
    }
  },

  connections: [{
    port: config.get('/server/port')
  }],

  plugins: plugins
};

/* some content omitted for brevity */

exports.run = function run () {

  return Uku.run(manifest, options);
};

installation

npm install -g heroku/uku

usage

$ uku help
Commands:
  project  Create a new uku project
  plugin   Generate a plugin

Options:
  --help  Show help                                                    [boolean]

peace, love, recycle

generate a new project

$ uku project my-project
my-project intialized at /Users/johnny/Desktop/my-project
Installing dependencies...

# npm output omitted for brevity

Dependency installation completed.

The generated project will resemble what you find here.

what you get out of the box

  • newrelic support via uku
  • rollbar support via icecreambar
  • forever for ensuring that a given script runs continuously
  • lab unit testing
    • originally a fork of mocha; very similar syntax
    • 100% code coverage out of the box
    • a few examples to get you started
  • eslint with a configured .eslintrc
  • recommended plugins such as
  • a convenient way to require additional plugins in ./plugins.js, including the ability to declare production-only plugins (e.g. https enforcement)
  • confidence and an accompying config.js which provides a great way to reference ENV-dependent values without polluting your code conditionals.
  • a valid package.json

generate a new plugin

$ uku plugin my-plugin
my-plugin intialized at /Users/johnny/Desktop/my-plugin
Installing dependencies...

# npm output omitted for brevity

Dependency installation completed.

what you get out of the box

  • a vanilla hapi plugin
  • lab unit testing
    • originally a fork of mocha; very similar syntax
    • 100% code coverage out of the box
    • a few examples to get you started
  • eslint with a configured .eslintrc
  • a valid package.json

About

node.js template for API services

Resources

License

Contributing

Stars

Watchers

Forks

Packages

No packages published

Contributors 3

  •  
  •  
  •