Nefarious Plastic Mannequins

    This package has been deprecated

    Author message:

    WARNING: This project has been renamed to 'feliz'.

    hapi-rx

    0.0.5 • Public • Published

    Hapi Rx

    A simple wrapper for Hapi.js & Socket.IO

    Usage

    index.js

    'use strict'
    const HapiRx = require('hapi-rx');
    
    const server$ = HapiRx({
        root: './app',
    });
    
    server$.subscribe(
        hapirx => console.log('Server running.'),
        err    => { throw err; }
    )
    

    app/routes.js

    'use strict';
    
    const Joi = require('joi');
    
    module.exports = {
    
        '/{id?}': {
            method: 'GET',
            bundle: 'root',
            config: {
                cache: false,
                validate: {
                    params:{
                        id: Joi.string().regex(/[a-f0-9]{24}/)
                    }
                }
            }
        },
    
        'action':{
            method: 'SOCKET',
            bundle: 'socket'
        },
    
    }
    

    app/bundles/root/index.js

    'use strict'
    
    module.exports = (request, reply){
        let path = this.path.bundles; // Access to the server instance
        if (request.params.id) return reply(`Hello ${request.params.id}`);
        reply('Hello world');
    }
    

    app/bundles/socket.js

    'use strict'
    // Still in alpha
    module.exports = (type, data){
        // emited using channel: socket:test
        if (type == 'test'){
            // do something with data
        }
    }
    

    Install

    npm i hapi-rx

    DownloadsWeekly Downloads

    6

    Version

    0.0.5

    License

    MIT

    Last publish

    Collaborators

    • etor