Security News
Weekly Downloads Now Available in npm Package Search Results
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.
@types/send
Advanced tools
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.
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);
Express is a web application framework for Node.js, designed for building web applications and APIs. It includes similar file serving capabilities through the 'express.static' middleware. While 'send' focuses solely on streaming files, Express provides a broader range of web server functionalities. The @types/express package offers TypeScript definitions for Express.
koa-send is a file serving utility for Koa, a web framework for Node.js. It is similar to 'send' but designed to work within the Koa ecosystem. koa-send supports serving files, setting custom headers, and more, tailored for Koa's middleware architecture. The @types/koa-send package provides TypeScript definitions for koa-send.
npm install --save @types/send
This package contains type definitions for send (https://github.com/pillarjs/send).
Files were exported from https://www.github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/send
Additional Details
These definitions were written by Mike Jerred https://github.com/MikeJerred.
FAQs
TypeScript definitions for send
The npm package @types/send receives a total of 15,517,147 weekly downloads. As such, @types/send popularity was classified as popular.
We found that @types/send demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
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.
Security News
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.
Security News
A Stanford study reveals 9.5% of engineers contribute almost nothing, costing tech $90B annually, with remote work fueling the rise of "ghost engineers."
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.