rutt
Angular inspired route config for Hapi
Last updated a month ago by artdude543 .
MIT · Repository · Original npm · Tarball · package.json
$ cnpm install rutt 
SYNC missed versions from official npm registry.

Rutt

Angular inspired route config for Hapi

Example

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));

Current Tags

  • 0.9.1                                ...           latest (a month ago)

15 Versions

  • 0.9.1                                ...           a month ago
  • 0.9.0                                ...           a month ago
  • 0.8.0                                ...           10 months ago
  • 0.7.2                                ...           a year ago
  • 0.7.1                                ...           a year ago
  • 0.7.0                                ...           2 years ago
  • 0.6.0                                ...           2 years ago
  • 0.5.0                                ...           3 years ago
  • 0.3.4                                ...           3 years ago
  • 0.3.3                                ...           3 years ago
  • 0.3.2                                ...           3 years ago
  • 0.3.1                                ...           3 years ago
  • 0.3.0                                ...           3 years ago
  • 0.2.0                                ...           3 years ago
  • 0.1.0                                ...           3 years ago
Downloads
Today 0
This Week 0
This Month 16
Last Day 15
Last Week 16
Last Month 33
Dependencies (4)
Dev Dependencies (4)
Dependents (0)
None

Copyright 2014 - 2016 © taobao.org |