@rayo/send
v1.2.0
Published
✈️ Rayo's response sender
Readme
Install
$> npm i @rayo/sendUse
import rayo from 'rayo';
import send from '@rayo/send';
rayo({ port: 5050 })
.through(send())
.get('/hello/:user', (req, res) => {
res.send({
message: `Hello ${req.params.user}. I was sent with headers!`
});
})
.start();send will attach itself to the ServerResponse (a.k.a res) and be callable as res.send().
res.send() will try to guess the content-type based on the payload and send the appropriate headers. It will also send a status code and end the response.
Note:
res.send()will incur a tiny performance hit due to the guess work and the headers being written with every response.
API
send()
Currently, it does not take any arguments.
