|
| 1 | +# chubbyts-http-multipart |
| 2 | + |
| 3 | +[](https://github.com/chubbyts/chubbyts-http-multipart/actions?query=workflow%3ACI) |
| 4 | +[](https://coveralls.io/github/chubbyts/chubbyts-http-multipart?branch=master) |
| 5 | +[](https://dashboard.stryker-mutator.io/reports/github.com/chubbyts/chubbyts-http-multipart/master) |
| 6 | +[](https://www.npmjs.com/package/@chubbyts/chubbyts-http-multipart) |
| 7 | + |
| 8 | +[](https://sonarcloud.io/dashboard?id=chubbyts_chubbyts-http-multipart) |
| 9 | +[](https://sonarcloud.io/dashboard?id=chubbyts_chubbyts-http-multipart) |
| 10 | +[](https://sonarcloud.io/dashboard?id=chubbyts_chubbyts-http-multipart) |
| 11 | +[](https://sonarcloud.io/dashboard?id=chubbyts_chubbyts-http-multipart) |
| 12 | +[](https://sonarcloud.io/dashboard?id=chubbyts_chubbyts-http-multipart) |
| 13 | +[](https://sonarcloud.io/dashboard?id=chubbyts_chubbyts-http-multipart) |
| 14 | +[](https://sonarcloud.io/dashboard?id=chubbyts_chubbyts-http-multipart) |
| 15 | +[](https://sonarcloud.io/dashboard?id=chubbyts_chubbyts-http-multipart) |
| 16 | +[](https://sonarcloud.io/dashboard?id=chubbyts_chubbyts-http-multipart) |
| 17 | +[](https://sonarcloud.io/dashboard?id=chubbyts_chubbyts-http-multipart) |
| 18 | +[](https://sonarcloud.io/dashboard?id=chubbyts_chubbyts-http-multipart) |
| 19 | + |
| 20 | +## Description |
| 21 | + |
| 22 | +Chubbyts Http multipart request handling. |
| 23 | + |
| 24 | +## Requirements |
| 25 | + |
| 26 | + * node: 16 |
| 27 | + * [@chubbyts/chubbyts-http-types][2]: ^1.2.3 |
| 28 | + * [busboy][3]: ^1.6.0 |
| 29 | + |
| 30 | +## Installation |
| 31 | + |
| 32 | +Through [NPM](https://www.npmjs.com) as [@chubbyts/chubbyts-http-multipart][1]. |
| 33 | + |
| 34 | +```sh |
| 35 | +npm i @chubbyts/chubbyts-http-multipart@^1.0.0 |
| 36 | +``` |
| 37 | + |
| 38 | +## Usage |
| 39 | + |
| 40 | +```ts |
| 41 | +import { createMultipartMiddleware } from '@chubbyts/chubbyts-http-multipart/dist/multipart-middleware'; |
| 42 | +import type { Handler } from '@chubbyts/chubbyts-http-types/dist/handler'; |
| 43 | +import type { Response, ServerRequest } from '@chubbyts/chubbyts-http-types/dist/message'; |
| 44 | + |
| 45 | +const request: ServerRequest = ...; |
| 46 | +const response: Response = ...; |
| 47 | + |
| 48 | +// if request original content-type was multipart/form-data, the current content-type and body is now application/x-www-form-urlencoded |
| 49 | +const handler: Handler = async (request: ServerRequest): Promise<Response> ...; |
| 50 | + |
| 51 | +const multipartMiddleware = createMultipartMiddleware(); |
| 52 | + |
| 53 | +const response = await multipartMiddleware(request, handler); |
| 54 | +``` |
| 55 | + |
| 56 | +## Copyright |
| 57 | + |
| 58 | +2024 Dominik Zogg |
| 59 | + |
| 60 | +[1]: https://www.npmjs.com/package/@chubbyts/chubbyts-http-multipart |
| 61 | +[2]: https://www.npmjs.com/package/@chubbyts/chubbyts-http-types |
| 62 | +[3]: https://www.npmjs.com/package/busboy |
0 commit comments