@tinyhttp/send
Advanced tools
Comparing version 2.0.9 to 2.1.0
import { parse, format } from "es-content-type"; | ||
import { eTag } from "@tinyhttp/etag"; | ||
import { Stats, statSync, createReadStream } from "fs"; | ||
import { STATUS_CODES } from "http"; | ||
import { isAbsolute, join, extname } from "path"; | ||
import { Stats, statSync, createReadStream } from "node:fs"; | ||
import { STATUS_CODES } from "node:http"; | ||
import { isAbsolute, join, extname } from "node:path"; | ||
import { contentType } from "es-mime-types"; | ||
@@ -7,0 +7,0 @@ const json = (res) => (body, ...args) => { |
@@ -1,2 +0,2 @@ | ||
import { ServerResponse as S } from 'http'; | ||
import { ServerResponse as S } from 'node:http'; | ||
type Res = Pick<S, 'setHeader' | 'end' | 'removeHeader'>; | ||
@@ -3,0 +3,0 @@ /** |
@@ -1,2 +0,2 @@ | ||
import { IncomingMessage as I, ServerResponse as S } from 'http'; | ||
import type { IncomingMessage as I, ServerResponse as S } from 'node:http'; | ||
type Req = Pick<I, 'method'> & { | ||
@@ -3,0 +3,0 @@ fresh?: boolean; |
@@ -1,2 +0,2 @@ | ||
import { IncomingMessage as I, ServerResponse as S } from 'http'; | ||
import type { IncomingMessage as I, ServerResponse as S } from 'node:http'; | ||
export type ReadStreamOptions = Partial<{ | ||
@@ -3,0 +3,0 @@ flags: string; |
@@ -1,2 +0,2 @@ | ||
import { IncomingMessage as I, ServerResponse as S } from 'http'; | ||
import { IncomingMessage as I, ServerResponse as S } from 'node:http'; | ||
type Req = Pick<I, 'method'>; | ||
@@ -3,0 +3,0 @@ type Res = Pick<S, 'setHeader' | 'removeHeader' | 'end' | 'getHeader' | 'statusCode'>; |
@@ -1,2 +0,2 @@ | ||
import { ServerResponse } from 'http'; | ||
import type { ServerResponse } from 'node:http'; | ||
type Res = Pick<ServerResponse, 'statusCode'>; | ||
@@ -3,0 +3,0 @@ /** |
@@ -1,4 +0,4 @@ | ||
import { Stats } from 'fs'; | ||
import { Stats } from 'node:fs'; | ||
export declare const createETag: (body: Buffer | string | Stats, encoding: BufferEncoding) => string; | ||
export declare function setCharset(type: string, charset: string): any; | ||
//# sourceMappingURL=utils.d.ts.map |
{ | ||
"name": "@tinyhttp/send", | ||
"version": "2.0.9", | ||
"version": "2.1.0", | ||
"type": "module", | ||
@@ -25,3 +25,3 @@ "description": "json, send, sendFile, status and sendStatus methods for tinyhttp", | ||
"engines": { | ||
"node": ">=12.4.0" | ||
"node": ">=12.20.0" | ||
}, | ||
@@ -33,3 +33,3 @@ "author": "v1rtl", | ||
"es-mime-types": "^0.1.4", | ||
"@tinyhttp/etag": "2.0.7" | ||
"@tinyhttp/etag": "2.1.0" | ||
}, | ||
@@ -36,0 +36,0 @@ "scripts": { |
# @tinyhttp/send | ||
[![npm (scoped)][npm-badge]](https://npmjs.com/package/@tinyhttp/send) [![npm][dl-badge]](https://npmjs.com/package/@tinyhttp/send) [![][web-badge]](https://tinyhttp.v1rtl.site/mw/send) | ||
[![npm (scoped)][npm-badge]](https://npmjs.com/package/@tinyhttp/send) | ||
[![npm][dl-badge]](https://npmjs.com/package/@tinyhttp/send) | ||
[![][web-badge]](https://tinyhttp.v1rtl.site/mw/send) | ||
Extensions for sending a response, including `send`, `sendStatus`, `status`, `sendFile` and `json`. Works with any backend framework. | ||
Extensions for sending a response, including `send`, `sendStatus`, `status`, | ||
`sendFile` and `json`. Works with any backend framework. | ||
@@ -16,3 +19,3 @@ ## Install | ||
```js | ||
import { send, sendStatus, status, json } from '@tinyhttp/send' | ||
import { json, send, sendStatus, status } from '@tinyhttp/send' | ||
``` | ||
@@ -38,5 +41,8 @@ | ||
Sends a JSON response. This method sends a response (with the correct content-type) that is the parameter converted to a JSON string using [`JSON.stringify()`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/stringify). | ||
Sends a JSON response. This method sends a response (with the correct | ||
content-type) that is the parameter converted to a JSON string using | ||
[`JSON.stringify()`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/stringify). | ||
The parameter can be any JSON type, including object, array, string, boolean, number, or null, and you can also use it to convert other values to JSON. | ||
The parameter can be any JSON type, including object, array, string, boolean, | ||
number, or null, and you can also use it to convert other values to JSON. | ||
@@ -53,3 +59,4 @@ ##### Example | ||
Sets the HTTP status for the response. It is a chainable alias of Node’s `response.statusCode`. | ||
Sets the HTTP status for the response. It is a chainable alias of Node’s | ||
`response.statusCode`. | ||
@@ -65,3 +72,4 @@ ##### Example | ||
Sets the response HTTP status code to statusCode and send its string representation as the response body. | ||
Sets the response HTTP status code to statusCode and send its string | ||
representation as the response body. | ||
@@ -77,9 +85,12 @@ ##### Example | ||
If an unsupported status code is specified, the HTTP status is still set to statusCode and the string version of the code is sent as the response body. | ||
If an unsupported status code is specified, the HTTP status is still set to | ||
statusCode and the string version of the code is sent as the response body. | ||
### `sendFile` [![][doc-badge]](https://tinyhttp.v1rtl.site/docs#ressendfile) | ||
Sends a file by piping a stream to response. It also checks for extension to set a proper `Content-Type` header. | ||
Sends a file by piping a stream to response. It also checks for extension to set | ||
a proper `Content-Type` header. | ||
> Path argument must be absolute. To use a relative path, specify the `root` option first. | ||
> Path argument must be absolute. To use a relative path, specify the `root` | ||
> option first. | ||
@@ -95,3 +106,3 @@ ##### Example | ||
```js | ||
import { createServer } from 'http' | ||
import { createServer } from 'node:http' | ||
import { send } from '@tinyhttp/send' | ||
@@ -98,0 +109,0 @@ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Network access
Supply chain riskThis module accesses the network.
Found 1 instance in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
37448
111
0
0
+ Added@tinyhttp/etag@2.1.0(transitive)
- Removed@tinyhttp/etag@2.0.7(transitive)
Updated@tinyhttp/etag@2.1.0