@rayo/send

1.2.0 • Public • Published
@rayo/send

Install

$> npm i @rayo/send

Use

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.

License

MIT

Readme

Keywords

none

Package Sidebar

Install

npm i @rayo/send

Weekly Downloads

50

Version

1.2.0

License

MIT

Unpacked Size

3.91 kB

Total Files

4

Last publish

Collaborators

  • saichholzer