Giter Club home page Giter Club logo

haute-couture's Introduction

haute-couture

File-based hapi plugin composer

Build Status Coverage Status

Lead Maintainer - Devin Ivy

Introduction

Note, this library is intended to work with hapi v17+

This library will wire your hapi plugin together based simply upon where you place files. It has the ability to call every configuration-related method in the hapi plugin API. This means many good things.

To name a few,

  • Route configurations placed in your routes/ directory will be registered using server.route().
  • You can place your authentication scheme in auth/schemes.js rather than calling server.auth.scheme().
  • You can provision a cache simply by placing its configuration in caches/my-cache-name.js, and forget about server.cache.provision().
  • Where applicable, any of these files can be configured as JSON.
  • You can teach haute-couture how to use your own custom server decorations.
  • You can still write all the custom plugin code you desire.

Again, haute-couture understands 17 hapi plugin methods– those for server methods, server/request decorations, request lifecycle extensions, route configuration, cookie definitions, vision view managers, schwifty models, schmervice services, and plenty more. It can also be used as an alternative to glue for composing a server.

Usage

See also the API Reference

This library is actually not used as a hapi plugin. Think of it instead as a useful subroutine of any hapi plugin. The full documentation of the files and directories it recognizes can be found in the API.

Here's an example of a very simple plugin that registers a single "pinger" route.

index.js

const HauteCouture = require('haute-couture');

// Either...
// 1. a plugin wired with haute-couture plus custom logic
module.exports = {
  name: 'my-hapi-plugin',
  register: async (server, options) => {

    // Do custom plugin duties

    await HauteCouture.using()(server, options);
  }
};

// 2. a plugin entirely wired using haute-couture
module.exports = {
  name: 'my-hapi-plugin',
  register: HauteCouture.using()
};

routes/pinger.js

// Note, this could also export an array of routes
module.exports = {
  method: 'get',
  path: '/',
  options: {
    // The route id 'pinger' will be assigned
    // automatically from the filename
    handler: (request) => {

      return { ping: 'pong' };
    }
  }
};

haute-couture's People

Contributors

devinivy avatar michaelhue avatar zemccartney avatar wswoodruff avatar

Watchers

James Cloos avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.