Skip to content

Latest commit

History

34 Commits

Folders and files

NameName
Last commit message
Last commit date

Repository files navigation

ResSender

ResSendr - Friendly request handlers.

Installing

$ npm install ressendr --save

Using

before

app.get('/hello',requestHandler)functionrequestHandler(req,res){res.end('World!')}

after

importrfrom'ressendr'app.get('/hello',r.handle(requestHandler))functionrequestHandler(req){return'World!';}

Using with promises

before

app.get('/hello',requestHandler)functionrequestHandler(req,res){asyncIO.get().then((response)=>{res.end(response);})}

after

importrfrom'ressendr'app.get('/hello',r.handle(requestHandler))functionrequestHandler(req){returnasyncIO.get()}

Writing your own handlers

importrfrom'ressendr'//First we need a function that returns true or false//true if the data can be handle by the handler.//so lets write a number HandlerletisNumber=value=>!isNaN(value);//Now we need to handle the value and send it.lethandler=(v,res)=>res.end(v.toString());r.addHandler(isNumber,handler);app.get('/hello',r.handle(requestHandler))functionrequestHandler(req,res){return2}

About

Friendly response handlers.

Resources

Stars

81 stars

Watchers

21 watching

Forks

Releases

Packages

Used by

Contributors

Languages