
Company News
Socket Named Top Sales Organization by RepVue
Socket won two 2026 Reppy Awards from RepVue, ranking in the top 5% of all sales orgs. AE Alexandra Lister shares what it's like to grow a sales career here.
@polka/send-type
Advanced tools
An HTTP response helper that detects
Content-Types & handles them accordingly — not limited to Polka!
For a simpler, bare-bones alternative, check out @polka/send instead~
$ npm install --save @polka/send-type
const { createReadStream } = require('fs');
const send = require('@polka/send-type');
module.exports = function (req, res) {
if (!req.getHeader('authorization')) {
// Objects are converted to JSON
return send(res, 401, { error:'Token required!' });
}
// Streams & Buffers are auto-piped
// Your 'Content-Type' is always used,
// ~> otherwise 'application/octet-stream'
let file = createReadStream('massive.mp4');
send(res, 206, file, { 'Content-Type': 'video/mp4' });
}
Type: ServerReponse
The outgoing HTTP response.
Type: Number
Default: 200
The statusCode for your response.
Type: String
Default: ''
The body for your response. Defaults to the statusText for the given statusCode.
See Data Detections for special behaviors.
Type: Object
Default: {}
The headers for your response.
The Content-Type header is a little unique – it will be set with the value you provide in headers. However, if you did not set a value explicitly, then send-type will reuse the existing value via res.getHeader.
If neither existed, then the Content-Type will be inferred by the data type.
See Data Detections for special behaviors.
The following operations will be performed for the following data types:
Important: If this is too much magic for you, check out
@polka/sendinstead!
Content-Type to 'application/octet-stream', unless one exists in headersContent-Lengthdata to string via JSON.stringifyContent-Type to 'application/json; charset=utf-8', unless one exists in headersContent-LengthContent-Type to 'application/octet-stream', unless one exists in headersdata into the res directlyAny issues or questions can be sent to the Polka repo, but please specify that you are using @polka/send-type.
MIT © Luke Edwards
FAQs
A response helper that detects & handles Content-Types
The npm package @polka/send-type receives a total of 181,424 weekly downloads. As such, @polka/send-type popularity was classified as popular.
We found that @polka/send-type 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.

Company News
Socket won two 2026 Reppy Awards from RepVue, ranking in the top 5% of all sales orgs. AE Alexandra Lister shares what it's like to grow a sales career here.

Security News
NIST will stop enriching most CVEs under a new risk-based model, narrowing the NVD's scope as vulnerability submissions continue to surge.

Company News
/Security News
Socket is an initial recipient of OpenAI's Cybersecurity Grant Program, which commits $10M in API credits to defenders securing open source software.