{"id":13515485,"url":"https://github.com/mafintosh/turbo-http","last_synced_at":"2025-04-08T15:07:08.865Z","repository":{"id":51080254,"uuid":"123466276","full_name":"mafintosh/turbo-http","owner":"mafintosh","description":"Blazing fast low level http server","archived":false,"fork":false,"pushed_at":"2019-05-09T20:18:48.000Z","size":42,"stargazers_count":1001,"open_issues_count":16,"forks_count":46,"subscribers_count":35,"default_branch":"master","last_synced_at":"2025-04-01T14:11:11.279Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"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/mafintosh.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-03-01T17:08:07.000Z","updated_at":"2025-02-11T15:50:15.000Z","dependencies_parsed_at":"2022-09-09T15:12:10.968Z","dependency_job_id":null,"html_url":"https://github.com/mafintosh/turbo-http","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mafintosh%2Fturbo-http","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mafintosh%2Fturbo-http/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mafintosh%2Fturbo-http/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mafintosh%2Fturbo-http/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mafintosh","download_url":"https://codeload.github.com/mafintosh/turbo-http/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247867361,"owners_count":21009240,"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-08-01T05:01:11.854Z","updated_at":"2025-04-08T15:07:08.834Z","avatar_url":"https://github.com/mafintosh.png","language":"JavaScript","funding_links":[],"categories":["JavaScript"],"sub_categories":[],"readme":"# turbo-http\n\nA low level http library for Node.js based on [turbo-net](https://github.com/mafintosh/turbo-net)\n\n```\nnpm i turbo-http\n```\n\n[![build status](https://travis-ci.org/mafintosh/turbo-http.svg?branch=master)](https://travis-ci.org/mafintosh/turbo-http)\n\nWIP, this module is already *really* fast but there are some HTTP features\nmissing and easy performance gains to be had. :D :D :D\n\nOn my laptop I can serve simple hello world payloads at around 100k requests/seconds compared to 10k requests/second using node core.\n\n## Usage\n\n``` js\nconst turbo = require('turbo-http')\n\nconst server = turbo.createServer(function (req, res) {\n  res.setHeader('Content-Length', '11')\n  res.write(Buffer.from('hello world'))\n})\n\nserver.listen(8080)\n```\n\n## API\n\n#### `server = turbo.createServer([onrequest])`\n\nCreate a new http server. Inherits from [the turbo-net tcp server](https://github.com/mafintosh/turbo-net#server--turbocreateserveroptions-onsocket)\n\n#### `server.on('request', req, res)`\n\nEmitted when a new http request is received.\n\n#### `res.statusCode = code`\n\nSet the http status\n\n#### `res.setHeader(name, value)`\n\nSet a http header\n\n#### `res.write(buf, [length], [callback])`\n\nWrite a buffer. When the callback is called, the buffer\nhas been *completely* flushed to the underlying socket and is safe to\nreuse for other purposes\n\n#### `res.writev(buffers, [lengths], [callback])`\n\nWrite more that one buffer at once.\n\n#### `res.end([buf], [length], [callback]`)\n\nEnd the request. Only needed if you do not provide a `Content-Length`.\n\n#### `req.url`\n\nRequest url\n\n#### `req.method`\n\nRequest method\n\n#### `req.socket`\n\nRequest [turbo-net](https://github.com/mafintosh/turbo-net) socket\n\n#### `value = req.getHeader(name)`\n\nGet a request header.\n\n#### `headers = req.getAllHeaders()`\n\nGet all request headers as a map.\n\n#### `req.ondata(buffer, start, length)`\n\nCalled when there is data read. If you use the buffer outside of this function\nyou should copy it.\n\n#### `req.onend()`\n\nCalled when the request is fully read.\n\n\n## Benchmarks\n\nComparing `turbo-http` to other frameworks is like comparing oranges to apples.\n`turbo-http` could be thought of as a replacement of Node's native [http](https://nodejs.org/api/http.html) module, while all available frameworks actually use it.\n\nBenchmark it:\n- `clone this repo`,\n- `npm i`\n- `npm run bench`\n\nBenchmark averages are taken after one warm-up round.\n\n\u0026nbsp;        | Requests/s | Latency | Throughput/Mb\n------------- | ---------- | ------- | --------------\nturbo-http.js | 32592      | 3.03    | 2.43\nbare-node.js  | 18396      | 5.32    | 1.98\nrayo.js       | 16249.6    | 6.03    | 1.77\npolka.js      | 15802.4    | 6.2     | 1.71\nfastify.js    | 15141.6    | 6.47    | 2.26\nexpress.js    | 13408.8    | 7.31    | 1.46\nhapi.js       | 9675.6     | 10.15   | 1.42\n\n\u003e **Note:** Nevermind these numbers, this benchmark was run on a slow computer and the above table is for illustrative purposes only.\n\nOptionally, you may also define your test's parameters:\n```\n$\u003e npm run bench -- -u http://localhost:5050 -c 100 -p 10 -d 5\n```\n* `-u` (_url_) -Defaults to `http://localhost:5050`\n* `-c` (_connections_) -Defaults to `100`\n* `-p` (_pipelines_) -Defaults to `10`\n* `-d` (_duration_) -Defaults to `5` (seconds)\n\n\n## Acknowledgements\n\nThis project was kindly sponsored by [nearForm](http://nearform.com).\n\n## License\n\nMIT\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmafintosh%2Fturbo-http","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmafintosh%2Fturbo-http","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmafintosh%2Fturbo-http/lists"}