@remix-run/method-override-middleware 0.1.1 → 0.1.2

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,8 +1,12 @@
1
1
  import type { Middleware } from '@remix-run/fetch-router';
2
+ /**
3
+ * Options for the `methodOverride` middleware.
4
+ */
2
5
  export interface MethodOverrideOptions {
3
6
  /**
4
7
  * The name of the form field to check for request method override.
5
- * Default is `_method`.
8
+ *
9
+ * @default '_method'
6
10
  */
7
11
  fieldName?: string;
8
12
  }
@@ -12,7 +16,7 @@ export interface MethodOverrideOptions {
12
16
  * Note: This middleware must be placed after the `formData` middleware in the middleware chain, or
13
17
  * some other middleware that provides `context.formData`.
14
18
  *
15
- * @param options (optional) Options for the method override middleware
19
+ * @param options Options for the method override middleware
16
20
  * @returns A middleware that overrides `context.method` with the value of the method override field
17
21
  */
18
22
  export declare function methodOverride(options?: MethodOverrideOptions): Middleware;
@@ -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,MAAM,WAAW,qBAAqB;IACpC;;;OAGG;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;;;;;;;;GAQG;AACH,wBAAgB,cAAc,CAAC,OAAO,CAAC,EAAE,qBAAqB,GAAG,UAAU,CAe1E"}
@@ -5,12 +5,12 @@ import { RequestMethods } from '@remix-run/fetch-router';
5
5
  * Note: This middleware must be placed after the `formData` middleware in the middleware chain, or
6
6
  * some other middleware that provides `context.formData`.
7
7
  *
8
- * @param options (optional) Options for the method override middleware
8
+ * @param options Options for the method override middleware
9
9
  * @returns A middleware that overrides `context.method` with the value of the method override field
10
10
  */
11
11
  export function methodOverride(options) {
12
12
  let fieldName = options?.fieldName ?? '_method';
13
- return async (context) => {
13
+ return (context) => {
14
14
  let method = context.formData?.get(fieldName);
15
15
  if (typeof method !== 'string') {
16
16
  return;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@remix-run/method-override-middleware",
3
- "version": "0.1.1",
3
+ "version": "0.1.2",
4
4
  "description": "Middleware for overriding HTTP request methods from form data",
5
5
  "author": "Michael Jackson <mjijackson@gmail.com>",
6
6
  "license": "MIT",
@@ -27,12 +27,12 @@
27
27
  },
28
28
  "devDependencies": {
29
29
  "@types/node": "^24.6.0",
30
- "typescript": "^5.9.3",
31
- "@remix-run/fetch-router": "0.12.0",
32
- "@remix-run/form-data-middleware": "0.1.0"
30
+ "@typescript/native-preview": "7.0.0-dev.20251125.1",
31
+ "@remix-run/fetch-router": "0.15.1",
32
+ "@remix-run/form-data-middleware": "0.1.2"
33
33
  },
34
- "peerDependencies": {
35
- "@remix-run/fetch-router": "^0.12.0"
34
+ "dependencies": {
35
+ "@remix-run/fetch-router": "^0.15.1"
36
36
  },
37
37
  "keywords": [
38
38
  "fetch",
@@ -42,9 +42,9 @@
42
42
  "http-method"
43
43
  ],
44
44
  "scripts": {
45
- "build": "tsc -p tsconfig.build.json",
45
+ "build": "tsgo -p tsconfig.build.json",
46
46
  "clean": "git clean -fdX",
47
- "test": "node --disable-warning=ExperimentalWarning --test './src/**/*.test.ts'",
48
- "typecheck": "tsc --noEmit"
47
+ "test": "node --disable-warning=ExperimentalWarning --test",
48
+ "typecheck": "tsgo --noEmit"
49
49
  }
50
50
  }
@@ -1,10 +1,14 @@
1
1
  import { RequestMethods } from '@remix-run/fetch-router'
2
2
  import type { Middleware, RequestContext, RequestMethod } from '@remix-run/fetch-router'
3
3
 
4
+ /**
5
+ * Options for the `methodOverride` middleware.
6
+ */
4
7
  export interface MethodOverrideOptions {
5
8
  /**
6
9
  * The name of the form field to check for request method override.
7
- * Default is `_method`.
10
+ *
11
+ * @default '_method'
8
12
  */
9
13
  fieldName?: string
10
14
  }
@@ -15,13 +19,13 @@ export interface MethodOverrideOptions {
15
19
  * Note: This middleware must be placed after the `formData` middleware in the middleware chain, or
16
20
  * some other middleware that provides `context.formData`.
17
21
  *
18
- * @param options (optional) Options for the method override middleware
22
+ * @param options Options for the method override middleware
19
23
  * @returns A middleware that overrides `context.method` with the value of the method override field
20
24
  */
21
25
  export function methodOverride(options?: MethodOverrideOptions): Middleware {
22
26
  let fieldName = options?.fieldName ?? '_method'
23
27
 
24
- return async (context: RequestContext) => {
28
+ return (context: RequestContext) => {
25
29
  let method = context.formData?.get(fieldName)
26
30
  if (typeof method !== 'string') {
27
31
  return