Socket
Socket
Sign inDemoInstall

@types/send

Package Overview
Dependencies
3
Maintainers
1
Versions
12
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    @types/send

TypeScript definitions for send


Version published
Weekly downloads
15M
decreased by-0.79%
Maintainers
1
Install size
3.90 MB
Created
Weekly downloads
 

Package description

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

Readme

Source

Installation

npm install --save @types/send

Summary

This package contains type definitions for send (https://github.com/pillarjs/send).

Details

Files were exported from https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/send.

Additional Details

  • Last updated: Tue, 07 Nov 2023 15:11:36 GMT
  • Dependencies: @types/mime, @types/node

Credits

These definitions were written by Mike Jerred, and Piotr Błażejewicz.

FAQs

Last updated on 07 Nov 2023

Did you know?

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc