servie-send
TypeScript icon, indicating that this package has built-in type declarations

2.0.0 • Public • Published

Servie Send

NPM version NPM downloads Build status Test coverage

Create a HTTP response to send using Servie - a thin layer for creating a Response object with cache headers.

Installation

npm install servie-send --save

Usage

import {
  sendText,
  sendHtml,
  sendJson,
  sendStream,
  sendEmpty,
  entityTag
} from "servie-send";
 
function handle(req) {
  return sendText(req, "hello world!");
  return sendHtml(req, "<!doctype html>");
  return sendJson(req, { json: true });
  return sendStream(req, fs.createReadStream("example.txt"));
  return sendEmpty(req); // Nothing in response.
}

Options

  • status? Change the default response status code (200).
  • headers? Define the headers to use for the response.
  • contentType? Define content length for the response.
  • contentLength? Define content length for the response.
  • mtime? Define the modification Date for the response.
  • etag? Define an ETag for the response (e.g. pre-computed with entityTag() or true for on-demand).

TypeScript

This project is written using TypeScript and publishes the definitions directly to NPM.

License

Apache 2.0

Package Sidebar

Install

npm i servie-send

Weekly Downloads

6

Version

2.0.0

License

Apache-2.0

Unpacked Size

28.8 kB

Total Files

9

Last publish

Collaborators

  • blakeembrey