@remix-run/method-override-middleware 0.1.4 → 0.1.6

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.
@@ -1,6 +1,6 @@
1
1
  import type { Middleware } from '@remix-run/fetch-router';
2
2
  /**
3
- * Options for the `methodOverride` middleware.
3
+ * Options for the {@link methodOverride} middleware.
4
4
  */
5
5
  export interface MethodOverrideOptions {
6
6
  /**
@@ -13,8 +13,9 @@ export interface MethodOverrideOptions {
13
13
  /**
14
14
  * Middleware that overrides `context.method` with the value of the method override field.
15
15
  *
16
- * Note: This middleware must be placed after the `formData` middleware in the middleware chain, or
17
- * some other middleware that provides `context.formData`.
16
+ * Note: This middleware must be placed after the
17
+ * {@link import('@remix-run/form-data-middleware').formData} middleware in the middleware
18
+ * chain, or some other middleware that provides `context.get(FormData)`.
18
19
  *
19
20
  * @param options Options for the method override middleware
20
21
  * @returns A middleware that overrides `context.method` with the value of the method override field
@@ -1 +1 @@
1
- {"version":3,"file":"method-override.d.ts","sourceRoot":"","sources":["../../src/lib/method-override.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,UAAU,EAAiC,MAAM,yBAAyB,CAAA;AAExF;;GAEG;AACH,MAAM,WAAW,qBAAqB;IACpC;;;;OAIG;IACH,SAAS,CAAC,EAAE,MAAM,CAAA;CACnB;AAED;;;;;;;;GAQG;AACH,wBAAgB,cAAc,CAAC,OAAO,CAAC,EAAE,qBAAqB,GAAG,UAAU,CAe1E"}
1
+ {"version":3,"file":"method-override.d.ts","sourceRoot":"","sources":["../../src/lib/method-override.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,UAAU,EAAiC,MAAM,yBAAyB,CAAA;AAExF;;GAEG;AACH,MAAM,WAAW,qBAAqB;IACpC;;;;OAIG;IACH,SAAS,CAAC,EAAE,MAAM,CAAA;CACnB;AAED;;;;;;;;;GASG;AACH,wBAAgB,cAAc,CAAC,OAAO,CAAC,EAAE,qBAAqB,GAAG,UAAU,CAe1E"}
@@ -2,8 +2,9 @@ import { RequestMethods } from '@remix-run/fetch-router';
2
2
  /**
3
3
  * Middleware that overrides `context.method` with the value of the method override field.
4
4
  *
5
- * Note: This middleware must be placed after the `formData` middleware in the middleware chain, or
6
- * some other middleware that provides `context.formData`.
5
+ * Note: This middleware must be placed after the
6
+ * {@link import('@remix-run/form-data-middleware').formData} middleware in the middleware
7
+ * chain, or some other middleware that provides `context.get(FormData)`.
7
8
  *
8
9
  * @param options Options for the method override middleware
9
10
  * @returns A middleware that overrides `context.method` with the value of the method override field
@@ -11,7 +12,7 @@ import { RequestMethods } from '@remix-run/fetch-router';
11
12
  export function methodOverride(options) {
12
13
  let fieldName = options?.fieldName ?? '_method';
13
14
  return (context) => {
14
- let method = context.formData?.get(fieldName);
15
+ let method = context.has(FormData) ? context.get(FormData).get(fieldName) : null;
15
16
  if (typeof method !== 'string') {
16
17
  return;
17
18
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@remix-run/method-override-middleware",
3
- "version": "0.1.4",
3
+ "version": "0.1.6",
4
4
  "description": "Middleware for overriding HTTP request methods from form data",
5
5
  "author": "Michael Jackson <mjijackson@gmail.com>",
6
6
  "license": "MIT",
@@ -28,11 +28,13 @@
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.17.0",
32
- "@remix-run/form-data-middleware": "0.1.4"
31
+ "@remix-run/assert": "0.1.0",
32
+ "@remix-run/fetch-router": "0.18.1",
33
+ "@remix-run/form-data-middleware": "0.2.1",
34
+ "@remix-run/test": "0.1.0"
33
35
  },
34
36
  "dependencies": {
35
- "@remix-run/fetch-router": "^0.17.0"
37
+ "@remix-run/fetch-router": "^0.18.1"
36
38
  },
37
39
  "keywords": [
38
40
  "fetch",
@@ -44,7 +46,7 @@
44
46
  "scripts": {
45
47
  "build": "tsgo -p tsconfig.build.json",
46
48
  "clean": "git clean -fdX",
47
- "test": "node --disable-warning=ExperimentalWarning --test",
49
+ "test": "remix-test",
48
50
  "typecheck": "tsgo --noEmit"
49
51
  }
50
52
  }
@@ -2,7 +2,7 @@ import { RequestMethods } from '@remix-run/fetch-router'
2
2
  import type { Middleware, RequestContext, RequestMethod } from '@remix-run/fetch-router'
3
3
 
4
4
  /**
5
- * Options for the `methodOverride` middleware.
5
+ * Options for the {@link methodOverride} middleware.
6
6
  */
7
7
  export interface MethodOverrideOptions {
8
8
  /**
@@ -16,8 +16,9 @@ export interface MethodOverrideOptions {
16
16
  /**
17
17
  * Middleware that overrides `context.method` with the value of the method override field.
18
18
  *
19
- * Note: This middleware must be placed after the `formData` middleware in the middleware chain, or
20
- * some other middleware that provides `context.formData`.
19
+ * Note: This middleware must be placed after the
20
+ * {@link import('@remix-run/form-data-middleware').formData} middleware in the middleware
21
+ * chain, or some other middleware that provides `context.get(FormData)`.
21
22
  *
22
23
  * @param options Options for the method override middleware
23
24
  * @returns A middleware that overrides `context.method` with the value of the method override field
@@ -26,7 +27,7 @@ export function methodOverride(options?: MethodOverrideOptions): Middleware {
26
27
  let fieldName = options?.fieldName ?? '_method'
27
28
 
28
29
  return (context: RequestContext) => {
29
- let method = context.formData?.get(fieldName)
30
+ let method = context.has(FormData) ? context.get(FormData).get(fieldName) : null
30
31
  if (typeof method !== 'string') {
31
32
  return
32
33
  }