@tinyhttp/send
Advanced tools
Comparing version 2.0.3 to 2.0.4
{ | ||
"name": "@tinyhttp/send", | ||
"version": "2.0.3", | ||
"version": "2.0.4", | ||
"type": "module", | ||
@@ -30,3 +30,3 @@ "description": "json, send, sendFile, status and sendStatus methods for tinyhttp", | ||
"dependencies": { | ||
"@tinyhttp/etag": "2.0.2", | ||
"@tinyhttp/etag": "2.0.3", | ||
"es-content-type": "^0.1.0", | ||
@@ -37,3 +37,4 @@ "es-mime-types": "^0.1.4" | ||
"build": "rollup -c" | ||
} | ||
}, | ||
"readme": "# @tinyhttp/send\n\n[![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)\n\nExtensions for sending a response, including `send`, `sendStatus`, `status`, `sendFile` and `json`. Works with any backend framework.\n\n## Install\n\n```sh\npnpm i @tinyhttp/send\n```\n\n## API\n\n```js\nimport { send, sendStatus, status, json } from '@tinyhttp/send'\n```\n\n### `send(body)` [![][doc-badge]](https://tinyhttp.v1rtl.site/docs#ressend)\n\nSends the HTTP response.\n\nThe body parameter can be a Buffer object, a string, an object, or an array.\n\n##### Example\n\n```ts\nres.send(Buffer.from('whoop'))\nres.send({ some: 'json' })\nres.send('<p>some html</p>')\nres.status(404).send('Sorry, we cannot find that!')\nres.status(500).send({ error: 'something blew up' })\n```\n\n### `json(body)` [![][doc-badge]](https://tinyhttp.v1rtl.site/docs#resjson)\n\nSends 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).\n\nThe 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.\n\n##### Example\n\n```ts\nres.json(null)\nres.json({ user: 'tobi' })\nres.status(500).json({ error: 'message' })\n```\n\n### `status(number)` [![][doc-badge]](https://tinyhttp.v1rtl.site/docs#resstatus)\n\nSets the HTTP status for the response. It is a chainable alias of Node’s `response.statusCode`.\n\n##### Example\n\n```ts\nres.status(403).end()\nres.status(400).send('Bad Request')\n```\n\n### `sendStatus` [![][doc-badge]](https://tinyhttp.v1rtl.site/docs#ressendstatus)\n\nSets the response HTTP status code to statusCode and send its string representation as the response body.\n\n##### Example\n\n```ts\nres.sendStatus(200) // equivalent to res.status(200).send('OK')\nres.sendStatus(403) // equivalent to res.status(403).send('Forbidden')\nres.sendStatus(404) // equivalent to res.status(404).send('Not Found')\nres.sendStatus(500) // equivalent to res.status(500).send('Internal Server Error')\n```\n\nIf 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.\n\n### `sendFile` [![][doc-badge]](https://tinyhttp.v1rtl.site/docs#ressendfile)\n\nSends a file by piping a stream to response. It also checks for extension to set a proper `Content-Type` header.\n\n> Path argument must be absolute. To use a relative path, specify the `root` option first.\n\n##### Example\n\n```js\nres.sendFile('song.mp3', { root: process.cwd() }, (err) => console.log(err))\n```\n\n## Example\n\n```js\nimport { createServer } from 'http'\nimport { send } from '@tinyhttp/send'\n\ncreateServer((req, res) => send(req, res)('Hello World')).listen(3000)\n```\n\n[npm-badge]: https://img.shields.io/npm/v/@tinyhttp/send?style=flat-square\n[dl-badge]: https://img.shields.io/npm/dt/@tinyhttp/send?style=flat-square\n[web-badge]: https://img.shields.io/badge/website-visit-hotpink?style=flat-square\n[doc-badge]: https://img.shields.io/badge/-docs-hotpink?style=flat-square\n" | ||
} |
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
18961
+ Added@tinyhttp/etag@2.0.3(transitive)
- Removed@tinyhttp/etag@2.0.2(transitive)
Updated@tinyhttp/etag@2.0.3