Security News
tea.xyz Spam Plagues npm and RubyGems Package Registries
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
@types/send
Advanced tools
Package description
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.
Readme
npm install --save @types/send
This package contains type definitions for send (https://github.com/pillarjs/send).
Files were exported from https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/send.
These definitions were written by Mike Jerred, and Piotr Błażejewicz.
FAQs
TypeScript definitions for send
The npm package @types/send receives a total of 14,439,502 weekly downloads. As such, @types/send popularity was classified as popular.
We found that @types/send demonstrated a healthy version release cadence and project activity because the last version was released less than 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
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
Security News
As cyber threats become more autonomous, AI-powered defenses are crucial for businesses to stay ahead of attackers who can exploit software vulnerabilities at scale.
Security News
UnitedHealth Group disclosed that the ransomware attack on Change Healthcare compromised protected health information for millions in the U.S., with estimated costs to the company expected to reach $1 billion.