hexi

0.8.1 • Public • Published

hexi

A hapi skin for express

Dependency Status Build Status npm version Coverage Status

Motivation

hapi is a great web framework that allows to write well structured servers. However, it has far less plugins and extensions than express (Node.js Framework Comparison: Express vs. Koa vs. Hapi). Hexi allows to write a web framework that has the well structured skeleton of a hapi server but uses express under the hood. As a consequence, a hexi app has the great structure of a hapi server and the wide variety of express middlewares available on npm.

Installation

npm install --save hexi

Basic Usage

// server.js
'use strict'
const express = require('express')
const hexi = require('hexi')
 
const app = express()
const server = hexi(app)
 
server.register([
  {
    register: require('hexi-default'),
  },
  {
    register: require('./hello-world-controller'),
  }
])
.then(() => {
  app.listen(8000)
})
 
// hello-world-controller.js
'use strict'
module.exports = (server, opts) => {
  server.route({
    method: 'GET',
    path: '/',
    handler (req, res) {
      res.send('Hello world!')
    },
  })
}

For samples of advanced usage see the hexi version of the hackathon starter.

License

MIT © Zoltan Kochan

Readme

Keywords

Package Sidebar

Install

npm i hexi

Weekly Downloads

3

Version

0.8.1

License

MIT

Last publish

Collaborators

  • zkochan