{"id":15767381,"url":"https://github.com/kikobeats/send-http","last_synced_at":"2025-08-28T22:32:04.797Z","repository":{"id":64126166,"uuid":"573059755","full_name":"Kikobeats/send-http","owner":"Kikobeats","description":"A `res.end` with data type detection.","archived":false,"fork":false,"pushed_at":"2023-11-30T18:03:59.000Z","size":45,"stargazers_count":4,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-10-17T17:57:44.834Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Kikobeats.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-12-01T15:59:41.000Z","updated_at":"2023-07-10T16:17:55.000Z","dependencies_parsed_at":"2024-10-04T13:22:05.544Z","dependency_job_id":"f7d08f6b-4147-49ee-918f-6457c23b6f74","html_url":"https://github.com/Kikobeats/send-http","commit_stats":{"total_commits":14,"total_committers":1,"mean_commits":14.0,"dds":0.0,"last_synced_commit":"33eacaf2e7a267afaa190217cc7d805e2c578eb3"},"previous_names":[],"tags_count":8,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Kikobeats%2Fsend-http","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Kikobeats%2Fsend-http/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Kikobeats%2Fsend-http/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Kikobeats%2Fsend-http/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Kikobeats","download_url":"https://codeload.github.com/Kikobeats/send-http/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":231303102,"owners_count":18355448,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-04T13:21:54.929Z","updated_at":"2024-12-26T03:11:23.852Z","avatar_url":"https://github.com/Kikobeats.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# send-http\n\n![Last version](https://img.shields.io/github/tag/Kikobeats/send-http.svg?style=flat-square)\n[![Coverage Status](https://img.shields.io/coveralls/Kikobeats/send-http.svg?style=flat-square)](https://coveralls.io/github/Kikobeats/send-http)\n[![NPM Status](https://img.shields.io/npm/dm/send-http.svg?style=flat-square)](https://www.npmjs.org/package/send-http)\n\n\u003e A straightforward way to send data for http.IncomingMessage.\n\nIt's like `res.send`, but:\n\n- It accepts any kind of value (number, string, object, stream, etc).\n- It checks http.IncomingMessage is writable before write.\n- It determines `Content-Type` based on the data type.\n- It optionally sets status code as third argument.\n- It's small (~50 LOC).\n\n## Install\n\n```bash\n$ npm install send-http --save\n```\n\n## Usage\n\n```js\nconst send = require('send-http')\nconst http = require('http')\nconst got = require('got')\n\nhttp.createServer((req, res) =\u003e {\n  /* send with no body */\n  send(res, 200)\n\n  /* send a string */\n  send(res, 200, 'foo')\n\n  /* send an object */\n  send(res, 200, { foo: 'bar' })\n\n  /* send a number */\n  send(res, 200, 1234)\n\n  /* send a buffer */\n  send(res, 200, Buffer.from('hello world'))\n\n  /* send a stream  */\n  send(res, 200, got.stream('https.//example.com'))\n})\n```\n\nAdditionally, you can `.create` to customize the behvaior before sending the data:\n\n```js\nconst send = require('send-http').create((res, data) =\u003e {\n  if (Buffer.byteLength(data) \u003e 6291456) {\n    throw new Error('Payload size is over 6mb')\n  }\n  return res.end(data)\n})\n```\n\n## License\n\n**send-http** © [Kiko Beats](https://kikobeats.com), released under the [MIT](https://github.com/Kikobeats/send-http/blob/master/LICENSE.md) License.\u003cbr\u003e\nAuthored and maintained by [Kiko Beats](https://kikobeats.com) with help from [contributors](https://github.com/Kikobeats/send-http/contributors).\n\n\u003e [kikobeats.com](https://kikobeats.com) · GitHub [Kiko Beats](https://github.com/Kikobeats) · Twitter [@Kikobeats](https://twitter.com/Kikobeats)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkikobeats%2Fsend-http","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkikobeats%2Fsend-http","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkikobeats%2Fsend-http/lists"}