0.0.17 • Published 9 years ago
feliz v0.0.17
Hapi Rx
A minimalistic wrapper for hapi.js to build servers
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
}
}0.1.0-beta.43
9 years ago
0.1.0-beta.40
9 years ago
0.0.57-beta
9 years ago
0.0.56-beta
9 years ago
0.0.55-beta
9 years ago
0.0.43
9 years ago
0.0.17
10 years ago
0.0.14
10 years ago
0.0.12
10 years ago
0.0.9
10 years ago
0.0.8
10 years ago
0.0.7
10 years ago
0.0.6
10 years ago
0.0.5
10 years ago