@remix-run/form-data-middleware 0.1.2 → 0.1.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +12 -5
- package/package.json +5 -5
package/README.md
CHANGED
|
@@ -1,11 +1,18 @@
|
|
|
1
1
|
# form-data-middleware
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Form body parsing middleware for Remix. It parses incoming [`FormData`](https://developer.mozilla.org/en-US/docs/Web/API/FormData) and exposes `context.formData` and uploaded files on `context.files`.
|
|
4
|
+
|
|
5
|
+
## Features
|
|
6
|
+
|
|
7
|
+
- **Request Form Parsing** - Parses request body form data once per request
|
|
8
|
+
- **File Access** - Exposes uploaded files as `context.files`
|
|
9
|
+
- **Custom Upload Handling** - Supports pluggable upload handlers for file processing
|
|
10
|
+
- **Error Control** - Optional suppression for malformed form data
|
|
4
11
|
|
|
5
12
|
## Installation
|
|
6
13
|
|
|
7
14
|
```sh
|
|
8
|
-
npm
|
|
15
|
+
npm i remix
|
|
9
16
|
```
|
|
10
17
|
|
|
11
18
|
## Usage
|
|
@@ -15,8 +22,8 @@ Use the `formData()` middleware at the router level to parse `FormData` from the
|
|
|
15
22
|
`context.files` will also be available as a map of `File` objects keyed by the name of the form field.
|
|
16
23
|
|
|
17
24
|
```ts
|
|
18
|
-
import { createRouter } from '
|
|
19
|
-
import { formData } from '
|
|
25
|
+
import { createRouter } from 'remix/fetch-router'
|
|
26
|
+
import { formData } from 'remix/form-data-middleware'
|
|
20
27
|
|
|
21
28
|
let router = createRouter({
|
|
22
29
|
middleware: [formData()],
|
|
@@ -38,7 +45,7 @@ router.post('/users', async (context) => {
|
|
|
38
45
|
You can use a custom upload handler to customize how file uploads are handled. The return value of the upload handler will be used as the value of the form field in the `FormData` object.
|
|
39
46
|
|
|
40
47
|
```ts
|
|
41
|
-
import { formData } from '
|
|
48
|
+
import { formData } from 'remix/form-data-middleware'
|
|
42
49
|
import { writeFile } from 'node:fs/promises'
|
|
43
50
|
|
|
44
51
|
let router = createRouter({
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@remix-run/form-data-middleware",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.4",
|
|
4
4
|
"description": "Middleware for parsing FormData from request bodies",
|
|
5
5
|
"author": "Michael Jackson <mjijackson@gmail.com>",
|
|
6
6
|
"license": "MIT",
|
|
@@ -28,12 +28,12 @@
|
|
|
28
28
|
"devDependencies": {
|
|
29
29
|
"@types/node": "^24.6.0",
|
|
30
30
|
"@typescript/native-preview": "7.0.0-dev.20251125.1",
|
|
31
|
-
"@remix-run/fetch-router": "0.
|
|
32
|
-
"@remix-run/form-data-parser": "0.
|
|
31
|
+
"@remix-run/fetch-router": "0.17.0",
|
|
32
|
+
"@remix-run/form-data-parser": "0.15.0"
|
|
33
33
|
},
|
|
34
34
|
"dependencies": {
|
|
35
|
-
"@remix-run/
|
|
36
|
-
"@remix-run/
|
|
35
|
+
"@remix-run/form-data-parser": "^0.15.0",
|
|
36
|
+
"@remix-run/fetch-router": "^0.17.0"
|
|
37
37
|
},
|
|
38
38
|
"keywords": [
|
|
39
39
|
"fetch",
|