# @gr2m/hapi-to-express

> Create Express.js response and request objects that bind to Hapi request and reply objects

Latest version **1.2.1-includes-6** (published 2016-09-13) · ISC license · 0 weekly downloads

## Install

```sh
npm install @gr2m/hapi-to-express
pnpm add @gr2m/hapi-to-express
yarn add @gr2m/hapi-to-express
bun add @gr2m/hapi-to-express
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.2.1-includes-6 |
| Published | 2016-09-13 |
| First published | 2016-09-13 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 7 |
| Author | jrpruit1 |
| Maintainers | gr2m |
| Keywords | express, hapi |

## Links

- npm: https://www.npmjs.com/package/@gr2m/hapi-to-express
- Repository: https://github.com/jrpruit1/hapi-to-express
- Issues: https://github.com/jrpruit1/hapi-to-express/issues
- npm.io page: https://npm.io/package/@gr2m/hapi-to-express

## Dependencies (1)

- [through2](https://npm.io/package/through2.md) ^2.0.0

## Recent versions

- 1.2.1-includes-6 (latest) — 2016-09-13

## README

# hapi-to-express

This module creates mocked Express request and response objects that internally call the Hapi request and reply objects .

[![NPM](https://nodei.co/npm/hapi-to-express.png)](https://nodei.co/npm/hapi-to-express/)
[![NPM](https://nodei.co/npm-dl/hapi-to-express.png)](https://nodei.co/npm-dl/hapi-to-express/)

## Usage

### params

**request** - a Hapi request object, ideally within a `'onPostAuth'` server extension point, so that `request.payload` can be read and written to.

**reply** - a Hapi reply object, also hopefully in the `'onPostAuth'` extension point.

### returns
  `{ res: ..., req: ... }` - an object where `res` represents an Express response object and `req` represents an Express request object. Very limited API at the moment.

## Example

```JavaScript
var hapiToExpress = require('hapi-to-express');
var cookieParser = require('cookie-parser');
    
server.ext('onPostAuth', function(request, reply) {
  var hapress = hapiToExpress(request, reply);

  cookieParser()(hapress.req, hapress.res, function(err) {
    if (err) { return reply(err); }
    reply.continue();
  });
});
```

## Note

Currently supporting a limited API based on Hapi 8.\* and Express 4.\* APIs.

---
_Source: https://npm.io/package/@gr2m/hapi-to-express · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
