@appjumpstart/mercury-send

1.0.0 • Public • Published

mercury-send

An Express/Connect-compatible middleware for sending HTTP responses

npm page appjumpstart chat

About

mercury-send is a super simple middleware that provides (or overrides) a res.send function that you can use in other middleware/route handlers. You can use it with Node's http.Server, Express, or any connect-compatible framework. To get the most benefit, you'll want to use it in tandem with mercury-schema which will provide mercury-send with a stringify function based on a pre-compiled response schema.

Installation

❯ npm install @appjumpstart/mercury-send --save

Usage

const mercurySend = require('@appjumpstart/mercury-send')

// ...

// Use the mercury-send middleware to more easily send responses.
app.use(mercurySend)

// Use res.send in your route-handler to send object that are converted to
// JSON using JSON.stringify or perhaps a stringify function provided by
// mercury-schema.
app.get('/', (req, res) => res.type('json').send({ message: 'Hello!' }))

Acknowledgement

mercury-send is completely modeled around some of the features within the excellent Fastify framework.

 

AppJumpstart

Package Sidebar

Install

npm i @appjumpstart/mercury-send

Weekly Downloads

2

Version

1.0.0

License

ISC

Unpacked Size

6.16 kB

Total Files

4

Last publish

Collaborators

  • ianwalter