# hecks

> Mount your express app onto your hapi server, aw heck!

Latest version **2.3.0** (published 2020-08-27) · MIT license · 0 weekly downloads

## Install

```sh
npm install hecks
pnpm add hecks
yarn add hecks
bun add hecks
```

## 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 | 2.3.0 |
| Published | 2020-08-27 |
| First published | 2017-03-06 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 2 |
| Unpacked size | 7.2 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 30 |
| Author | Devin Ivy |
| Maintainers | devinivy |
| Keywords | hapi, express, express on hapi, express with hapi |

## Links

- npm: https://www.npmjs.com/package/hecks
- Repository: https://github.com/hapipal/hecks
- Homepage: https://github.com/hapipal/hecks#readme
- Issues: https://github.com/hapipal/hecks/issues
- npm.io page: https://npm.io/package/hecks

## Dependencies (2)

- [toys](https://npm.io/package/toys.md) 2.x.x
- [@hapi/bounce](https://npm.io/package/@hapi/bounce.md) 1.x.x

## Recent versions

- 2.3.0 (latest) — 2020-08-27
- 2.2.0 — 2020-02-15
- 2.1.1 — 2019-05-25
- 2.1.0 — 2019-01-20
- 2.0.0 — 2018-01-06
- 1.0.1 — 2018-01-06
- 1.0.0 — 2017-03-10
- 0.0.1 — 2017-03-06
- 0.0.0 — 2017-03-06

## README

# hecks
Mount your express app onto your hapi server, aw heck!

[![Build Status](https://travis-ci.org/hapipal/hecks.svg?branch=master)](https://travis-ci.org/hapipal/hecks) [![Coverage Status](https://coveralls.io/repos/hapipal/hecks/badge.svg?branch=master&service=github)](https://coveralls.io/github/hapipal/hecks?branch=master)

Lead Maintainer - [Devin Ivy](https://github.com/devinivy)

## Usage
> See also the [API Reference](API.md)

Hecks allows you to seamlessly incorporate express applications into a **hapi v17+** server.  This is particularly useful for testing an express server using [`server.inject()`](https://github.com/hapijs/hapi/blob/master/API.md#server.inject()), for unifying deployment of existing express and hapi applications, and as an initial stepping stone in migrating an express application to hapi.

```js
const Express = require('express');
const BodyParser = require('body-parser');
const Hapi = require('@hapi/hapi');
const Hoek = require('@hapi/hoek');
const Hecks = require('hecks');

(async () => {

    const app = Express();

    app.post('/user', BodyParser.json(), (req, res) => {

        const user = Hoek.shallow(req.body);
        user.saved = true;

        res.json(user);
    });

    const server = Hapi.server();

    await server.register([
        Hecks.toPlugin(app, 'my-express-app')
    ]);

    const { result } = await server.inject({
        method: 'post',
        url: '/user',
        payload: { name: 'Bill', faveFood: 'cactus' }
    });

    console.log(result); // {"name":"Bill","faveFood":"cactus","saved":true}
})();
```

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