New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

rutt

Package Overview
Dependencies
Maintainers
2
Versions
17
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

rutt

Angular inspired route config for Hapi

latest
Source
npmnpm
Version
0.11.0
Version published
Maintainers
2
Created
Source

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

FAQs

Package last updated on 25 Dec 2022

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts