1.0.1 • Published 7 years ago

express-hapi v1.0.1

Weekly downloads
1
License
MIT
Repository
github
Last release
7 years ago

express hapi

Add a route method to an express app or router to create routes in a similar fashion to hapi.js

Install

npm install --save express-hapi
# or
yarn add express-hapi

Usage

const express = require('express');
const expressHapi = require('express-hapi');

const app = express();
expressHapi(app); // Add the route method to app

// Create a route using the added route method
app.route({  
    method: 'GET',
    path: '/',
    handler: (req, res, next) => {
      res.json({
        message: 'I\'m so hapi!'
      });
    }
});

// Above is equivalent to:
app.get('/', (req, res, next) => {
  res.json({
    message: 'I\'m so hapi!'
  });
});

const port = process.env.PORT || 3000;
app.listen(port, () =>{
  console.log(`Listening on ${port}`);
});