# rutt

> Angular inspired route config for Hapi

Latest version **0.11.0** (published 2022-12-25) · MIT license · 0 weekly downloads

## Install

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

## Health

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

Positive: has types; no vulnerabilities.

Warnings: low downloads; no esm support; pre 1.0.

Negative: abandoned.

## Facts

| | |
|---|---|
| Version | 0.11.0 |
| Published | 2022-12-25 |
| First published | 2016-10-24 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 4 |
| Unpacked size | 16.6 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 3 |
| Author | James Birtles |
| Maintainers | artdude543, unwrittenfun |

## Links

- npm: https://www.npmjs.com/package/rutt
- Repository: https://github.com/UnwrittenFun/rutt
- npm.io page: https://npm.io/package/rutt

## Dependencies (4)

- [joi](https://npm.io/package/joi.md) ^17.7.0
- [lodash](https://npm.io/package/lodash.md) ^4.17.21
- [@hapi/boom](https://npm.io/package/@hapi/boom.md) ^10.0.0
- [@hapi/hapi](https://npm.io/package/@hapi/hapi.md) ^21.1.0

## Recent versions

- 0.11.0 (latest) — 2022-12-25
- 0.10.0 — 2021-08-13
- 0.9.1 — 2020-01-16
- 0.9.0 — 2020-01-16
- 0.8.0 — 2019-04-12
- 0.7.2 — 2018-11-29
- 0.7.1 — 2018-11-29
- 0.7.0 — 2018-06-04
- 0.6.0 — 2018-04-09
- 0.5.0 — 2017-07-16
- 0.3.4 — 2017-01-25
- 0.3.3 — 2016-11-08
- 0.3.2 — 2016-10-31
- 0.3.1 — 2016-10-29
- 0.3.0 — 2016-10-29
- … 2 more at https://npm.io/package/rutt/versions

## README

# Rutt

Angular inspired route config for Hapi

## Example

```typescript
import { Rutt, Route, RuttRequest } from 'rutt';
import { Post } from './models/post';

class PostsController {
    listPosts() {
        return Post.all();
    }

    getPost(req: RuttRequest) {
        const postId = req.params['postId'];

        // Returned promises are automatically resolved
        return Post.find(postId);
    }

    createPost() {
        return Post.create({ title: '', body: '' });
    }
}

/**
 * Registers routes:
 * get  /posts
 * post /posts
 * get  /posts/{postId}
 */
const appRoutes: Route[] = [
    {
        path: 'posts',
        controller: PostsController,
        handler: 'listPosts',
        children: [
            { path: '', method: 'post', handler: 'createPost' },
            { path: ':postId', handler: 'getPost' },
        ],
    },
];

const rutt = new Rutt({ port: 3000 });
rutt.routes(appRoutes);

rutt.start()
    .then(() => console.log(`Server running at: ${rutt.server.info.uri}`))
    .catch(err => console.error('Error starting server', err));
```

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