0.1.5 • Published 7 years ago

ressendr v0.1.5

Weekly downloads
63
License
-
Repository
github
Last release
7 years ago

ResSender

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'


//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 Handler

let isNumber = value => !isNaN(value);

//Now we need to handle the value and send it.

let handler = (v,res) => res.end(v.toString());

r.addHandler(isNumber,handler);

app.get('/hello',r.handle(requestHandler))

function requestHandler(req, res){
  return 2
}
0.1.5

7 years ago

0.1.4

7 years ago

0.1.3

7 years ago

0.1.2

7 years ago

0.1.1

7 years ago

0.0.57

8 years ago

0.0.56

8 years ago

0.0.54

8 years ago

0.0.53

8 years ago

0.0.52

8 years ago

0.0.51

8 years ago

0.0.5

8 years ago

0.0.4

8 years ago

0.0.3

8 years ago

0.0.2

8 years ago

0.0.1

8 years ago

0.0.0

8 years ago

1.0.0

8 years ago