# hapi-router-coffee

> An Opinionated Route Loader for Hapi for CoffeeScript files.

Latest version **1.5.0** (published 2016-06-08) · MIT license · 0 weekly downloads

## Install

```sh
npm install hapi-router-coffee
pnpm add hapi-router-coffee
yarn add hapi-router-coffee
bun add hapi-router-coffee
```

## 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.5.0 |
| Published | 2016-06-08 |
| First published | 2015-02-28 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 2 |
| Known vulnerabilities | 0 (+6 in 1 direct dependencies) |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Ethan Mick |
| Maintainers | ethan_mick |
| Keywords | hapi, routes, router, coffee-script |

## Links

- npm: https://www.npmjs.com/package/hapi-router-coffee
- Repository: https://github.com/ethanmick/hapi-router-coffee
- Issues: https://github.com/ethanmick/hapi-router-coffee/issues
- npm.io page: https://npm.io/package/hapi-router-coffee

## Dependencies (2)

- [lodash](https://npm.io/package/lodash.md) 3.10.1
- [coffee-script](https://npm.io/package/coffee-script.md) 1.10.0

## Recent versions

- 1.5.0 (latest) — 2016-06-08
- 1.4.0 — 2016-06-08
- 1.3.0 — 2015-11-08
- 1.2.0 — 2015-03-22
- 1.1.0 — 2015-03-12
- 1.0.0 — 2015-02-28

## README

# Hapi Router Coffee
[![Build Status](https://travis-ci.org/ethanmick/hapi-router-coffee.svg?branch=master)](https://travis-ci.org/ethanmick/hapi-router-coffee.svg?branch=master) [![Coverage Status](https://coveralls.io/repos/ethanmick/hapi-router-coffee/badge.svg?branch=master)](https://coveralls.io/r/ethanmick/hapi-router-coffee?branch=master)

An Opinionated Route Loader for [Hapi](https://github.com/hapijs/hapi) for CoffeeScript files.

This fork does two things, which may interest you:  
1. Written in CoffeeScript (and **not** compiled to JS), so it can autoload .coffee files.  
2. Allows you to pass options to the routes, and merge in the options already on the route.  

## Setup

```bash
$ npm install hapi-router-coffee --save
```

I assume you're writing in CoffeeScript, right?
```coffee
server.register {
  register: require('hapi-router-coffee')
  options:
    routesDir: "#{__dirname}/routes/"
}, (err)->
  throw err if err
}
```

## Options

The following required `options` should be provided at registration:
* `routesDir`: the path to your routes directory
* `routesOptions` : Options to pass into the `config` of each route.

Note that the options are not really needed, since you can just use the Hapi server for options. This may be useful in the future though!

```coffee
server = new Hapi.Server({
    connections:
      routes:
        payload:
          timeout: no # Sets payload timeout to false on ALL routes.
})
```

## Specifying Routes
Any `.js` or `.coffee` files in your routes directory will be loaded - supports nested routes.

Example route file:
```js
module.exports = [
  {
    path: '/test1',
    method: 'GET',
    handler: function (request, reply) {
      reply('hello');
    }
  },
  {
    path: '/test2',
    method: 'GET',
    handler: function (request, reply) {
      reply('hello');
    }
  }
]
```

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