Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@types/send

Package Overview
Dependencies
Maintainers
1
Versions
12
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@types/send

TypeScript definitions for send

  • 0.14.3
  • ts2.0
  • ts2.1
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
19M
increased by2.67%
Maintainers
1
Weekly downloads
 
Created

What is @types/send?

The @types/send package provides TypeScript type definitions for the 'send' package, which is a utility for streaming files from the file system as an HTTP response. It supports directory indexes, conditional GET requests, and other high-level features. The @types/send package itself does not implement these functionalities but provides type definitions to help TypeScript developers use the 'send' package more effectively by offering compile-time type checking and IntelliSense support in code editors.

What are @types/send's main functionalities?

Serving a file

This code demonstrates how to serve a file using the 'send' package. It creates an HTTP server that listens on port 3000 and uses the 'send' function to stream a file from the file system to the response. The @types/send package provides type definitions for this usage.

import send from 'send';
import http from 'http';

http.createServer((req, res) => {
  send(req, '/path/to/file.txt').pipe(res);
}).listen(3000);

Setting custom headers

This example shows how to set custom HTTP headers before sending the file. It listens for the 'headers' event and then sets the 'Cache-Control' header. The @types/send package provides type definitions for these event handlers and method chaining.

import send from 'send';
import http from 'http';

http.createServer((req, res) => {
  send(req, '/path/to/file.txt')
    .on('headers', (res, path, stat) => {
      res.setHeader('Cache-Control', 'public, max-age=3600');
    })
    .pipe(res);
}).listen(3000);

Other packages similar to @types/send

FAQs

Package last updated on 05 Jul 2017

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc