README

Install
✈️ Rayo's response sender
<script type="module">
import rayoSend from 'https://cdn.skypack.dev/@rayo/send';
</script>
gt; npm i @rayo/send
const rayo = require('rayo');
const send = require('@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 performance hit due to the guess work and the headers being written with every response.
Currently, it does not take any arguments.