ResSendr - Friendly request handlers.
Installing
$ npm install ressendr --save
Using
before
app.get('/hello',requestHandler)
function requestHandler(req, res){
res.end('World!')
}
after
import r from 'ressendr'
app.get('/hello',r.handle(requestHandler))
function requestHandler(req){
return 'World!';
}
Using with promises
before
app.get('/hello',requestHandler)
function requestHandler(req, res){
asyncIO.get()
.then((response)=>{
res.end(response);
})
}
after
import r from 'ressendr'
app.get('/hello',r.handle(requestHandler))
function requestHandler(req){
return asyncIO.get()
}
Writing your own handlers
import r from 'ressendr'
let isNumber = value => !isNaN(value);
let handler = (v,res) => res.end(v.toString());
r.addHandler(isNumber,handler);
app.get('/hello',r.handle(requestHandler))
function requestHandler(req, res){
return 2
}