0.11.0 • Published 1 year ago

rutt v0.11.0

Weekly downloads
17
License
MIT
Repository
github
Last release
1 year ago

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

1 year ago

0.10.0

3 years ago

0.9.1

4 years ago

0.9.0

4 years ago

0.8.0

5 years ago

0.7.2

5 years ago

0.7.1

5 years ago

0.7.0

6 years ago

0.6.0

6 years ago

0.5.0

7 years ago

0.3.4

7 years ago

0.3.3

7 years ago

0.3.2

7 years ago

0.3.1

7 years ago

0.3.0

7 years ago

0.2.0

8 years ago

0.1.0

8 years ago