{"id":18096348,"url":"https://github.com/bredele/salute","last_synced_at":"2025-07-02T09:35:13.888Z","repository":{"id":65473399,"uuid":"97353651","full_name":"bredele/salute","owner":"bredele","description":"The best middleware for your HTTP request/response","archived":false,"fork":false,"pushed_at":"2017-12-18T23:00:48.000Z","size":16,"stargazers_count":2,"open_issues_count":1,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-06T03:27:20.993Z","etag":null,"topics":["chunk","http","middleware","request","response","stream"],"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/bredele.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":"2017-07-16T02:04:58.000Z","updated_at":"2018-04-19T06:32:26.000Z","dependencies_parsed_at":"2023-01-25T03:15:37.268Z","dependency_job_id":null,"html_url":"https://github.com/bredele/salute","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/bredele/salute","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bredele%2Fsalute","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bredele%2Fsalute/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bredele%2Fsalute/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bredele%2Fsalute/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/bredele","download_url":"https://codeload.github.com/bredele/salute/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bredele%2Fsalute/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":263112202,"owners_count":23415567,"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":["chunk","http","middleware","request","response","stream"],"created_at":"2024-10-31T19:13:47.747Z","updated_at":"2025-07-02T09:35:13.870Z","avatar_url":"https://github.com/bredele.png","language":"JavaScript","readme":"# Salute\n\n[![Build Status](https://travis-ci.org/bredele/salute.svg?branch=master)](https://travis-ci.org/bredele/salute)\n[![NPM](https://img.shields.io/npm/v/salute.svg?style=flat-square)](https://www.npmjs.com/package/salute)\n[![Downloads](https://img.shields.io/npm/dm/salute.svg?style=flat-square)](http://npm-stat.com/charts.html?package=salute)\n[![pledge](https://bredele.github.io/contributing-guide/community-pledge.svg)](https://github.com/bredele/contributing-guide/blob/master/community.md)\n\nSalute is a high order function you can use as a middleware for your HTTP servers:\n  * **Chunked encoding**: The data returned by your function is decomposed into series of chunks using [chunked transfer encoding](https://en.wikipedia.org/wiki/Chunked_transfer_encoding). Salute automatically reduce [time to first byte](https://en.wikipedia.org/wiki/Time_To_First_Byte) and work around the v8 heap memory limit while having low memory footprint.\n  * **Polymorphic**: Salute provides a single interface to process whatever data returned by your function. It even accepts promises of streams.\n  * **HTTP status**: Return an [HTTP error](https://www.npmjs.com/package/http-errors) to automatically send status with custom payload through the response.\n\n## Usage\n\n```javascript\nconst salute = require('salute')\nconst http = require('http')\nconst createError = require('http-errors')\n\n\nconst middleware = salute((req) =\u003e {\n  switch(req.url) {\n    case '/stream':\n      return fs.createReadStream('hello.txt')\n    case '/errors':\n      return createError(401, 'Please login')\n    default:\n      return 'hello world'\n  }\n})\n\n\nhttp.createServer((req, res) =\u003e {\n  middleware(req, res).pipe(res)\n})\n```\n\nSalute automatically know which type of data you want to send through the response and set the appropriate content type (text/plain for promises and streams). However, you can set the response header with a content type of your choice:\n\n```js\nsalute(fn, 'csv')\n```\n\n## Installation\n\n```shell\nnpm install salute --save\n```\n\n[![NPM](https://nodei.co/npm/salute.png)](https://nodei.co/npm/salute/)\n\n## Question\n\nFor questions and feedback please use our [twitter account](https://twitter.com/bredeleca). For support, bug reports and or feature requests please make sure to read our\n\u003ca href=\"https://github.com/bredele/contributing-guide/blob/master/community.md\" target=\"_blank\"\u003ecommunity guideline\u003c/a\u003e and use the issue list of this repo and make sure it's not present yet in our reporting checklist.\n\n## Contribution\n\nSalute is an open source project and would not exist without its community. If you want to participate please make sure to read our \u003ca href=\"https://github.com/bredele/contributing-guide/blob/master/community.md\" target=\"_blank\"\u003eguideline\u003c/a\u003e before making a pull request. If you have any salute-related project, component or other let everyone know in our wiki.\n\n\n## Licence\n\nThe MIT License (MIT)\n\nCopyright (c) 2016 Olivier Wietrich\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbredele%2Fsalute","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbredele%2Fsalute","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbredele%2Fsalute/lists"}