@kiyasov/platform-hono 1.1.6 → 1.1.8
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/dist/cjs/src/adapters/hono-adapter.js +2 -2
- package/dist/cjs/src/adapters/hono-adapter.js.map +1 -1
- package/dist/cjs/src/multer/interceptors/any-files-interceptor.d.ts +2 -2
- package/dist/cjs/src/multer/interceptors/any-files-interceptor.js +3 -0
- package/dist/cjs/src/multer/interceptors/any-files-interceptor.js.map +1 -1
- package/dist/cjs/src/multer/interceptors/file-fields-interceptor.d.ts +3 -3
- package/dist/cjs/src/multer/interceptors/file-fields-interceptor.js +3 -0
- package/dist/cjs/src/multer/interceptors/file-fields-interceptor.js.map +1 -1
- package/dist/cjs/src/multer/interceptors/file-interceptor.d.ts +2 -2
- package/dist/cjs/src/multer/interceptors/file-interceptor.js +3 -0
- package/dist/cjs/src/multer/interceptors/file-interceptor.js.map +1 -1
- package/dist/cjs/src/multer/interceptors/files-interceptor.d.ts +2 -2
- package/dist/cjs/src/multer/interceptors/files-interceptor.js +3 -0
- package/dist/cjs/src/multer/interceptors/files-interceptor.js.map +1 -1
- package/dist/cjs/src/multer/multipart/request.js +0 -2
- package/dist/cjs/src/multer/multipart/request.js.map +1 -1
- package/dist/cjs/tsconfig.cjs.tsbuildinfo +1 -1
- package/dist/esm/src/adapters/hono-adapter.js +2 -2
- package/dist/esm/src/adapters/hono-adapter.js.map +1 -1
- package/dist/esm/src/multer/interceptors/any-files-interceptor.d.ts +2 -2
- package/dist/esm/src/multer/interceptors/any-files-interceptor.js +8 -5
- package/dist/esm/src/multer/interceptors/any-files-interceptor.js.map +1 -1
- package/dist/esm/src/multer/interceptors/file-fields-interceptor.d.ts +3 -3
- package/dist/esm/src/multer/interceptors/file-fields-interceptor.js +8 -5
- package/dist/esm/src/multer/interceptors/file-fields-interceptor.js.map +1 -1
- package/dist/esm/src/multer/interceptors/file-interceptor.d.ts +2 -2
- package/dist/esm/src/multer/interceptors/file-interceptor.js +8 -5
- package/dist/esm/src/multer/interceptors/file-interceptor.js.map +1 -1
- package/dist/esm/src/multer/interceptors/files-interceptor.d.ts +2 -2
- package/dist/esm/src/multer/interceptors/files-interceptor.js +8 -5
- package/dist/esm/src/multer/interceptors/files-interceptor.js.map +1 -1
- package/dist/esm/src/multer/multipart/request.js +0 -2
- package/dist/esm/src/multer/multipart/request.js.map +1 -1
- package/dist/esm/tsconfig.esm.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/src/adapters/hono-adapter.ts +2 -2
- package/src/multer/interceptors/any-files-interceptor.ts +12 -8
- package/src/multer/interceptors/file-fields-interceptor.ts +12 -8
- package/src/multer/interceptors/file-interceptor.ts +12 -8
- package/src/multer/interceptors/files-interceptor.ts +12 -8
- package/src/multer/multipart/request.ts +0 -4
package/package.json
CHANGED
|
@@ -211,11 +211,11 @@ export class HonoAdapter extends AbstractHttpAdapter<
|
|
|
211
211
|
const contentType = ctx.req.header("content-type");
|
|
212
212
|
switch (type) {
|
|
213
213
|
case "application/json":
|
|
214
|
-
if (contentType
|
|
214
|
+
if (contentType?.startsWith("application/json"))
|
|
215
215
|
(ctx.req as any).body = await ctx.req.json();
|
|
216
216
|
break;
|
|
217
217
|
case "text/plain":
|
|
218
|
-
if (contentType
|
|
218
|
+
if (contentType?.startsWith("text/plain")) {
|
|
219
219
|
(ctx.req as any).rawBody = Buffer.from(await ctx.req.text());
|
|
220
220
|
(ctx.req as any).body = await ctx.req.json();
|
|
221
221
|
}
|
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
import { Observable, tap } from
|
|
1
|
+
import { Observable, tap } from "rxjs";
|
|
2
2
|
import {
|
|
3
3
|
CallHandler,
|
|
4
4
|
ExecutionContext,
|
|
5
5
|
mixin,
|
|
6
6
|
NestInterceptor,
|
|
7
7
|
Type,
|
|
8
|
-
} from
|
|
8
|
+
} from "@nestjs/common";
|
|
9
9
|
|
|
10
|
-
import { getMultipartRequest } from
|
|
11
|
-
import { transformUploadOptions, UploadOptions } from
|
|
12
|
-
import { handleMultipartAnyFiles } from
|
|
10
|
+
import { getMultipartRequest } from "../multipart/request";
|
|
11
|
+
import { transformUploadOptions, UploadOptions } from "../multipart/options";
|
|
12
|
+
import { handleMultipartAnyFiles } from "../multipart/handlers/any-files";
|
|
13
13
|
|
|
14
14
|
export function AnyFilesInterceptor(
|
|
15
|
-
options?: UploadOptions
|
|
15
|
+
options?: UploadOptions
|
|
16
16
|
): Type<NestInterceptor> {
|
|
17
17
|
class MixinInterceptor implements NestInterceptor {
|
|
18
18
|
private readonly options: UploadOptions;
|
|
@@ -23,14 +23,18 @@ export function AnyFilesInterceptor(
|
|
|
23
23
|
|
|
24
24
|
async intercept(
|
|
25
25
|
context: ExecutionContext,
|
|
26
|
-
next: CallHandler
|
|
26
|
+
next: CallHandler
|
|
27
27
|
): Promise<Observable<any>> {
|
|
28
28
|
const ctx = context.switchToHttp();
|
|
29
29
|
const req = getMultipartRequest(ctx);
|
|
30
30
|
|
|
31
|
+
if (!req.header("content-type")?.startsWith("multipart/form-data")) {
|
|
32
|
+
return next.handle();
|
|
33
|
+
}
|
|
34
|
+
|
|
31
35
|
const { body, files, remove } = await handleMultipartAnyFiles(
|
|
32
36
|
req,
|
|
33
|
-
this.options
|
|
37
|
+
this.options
|
|
34
38
|
);
|
|
35
39
|
|
|
36
40
|
req.body = body;
|
|
@@ -1,24 +1,24 @@
|
|
|
1
|
-
import { Observable, tap } from
|
|
1
|
+
import { Observable, tap } from "rxjs";
|
|
2
2
|
import {
|
|
3
3
|
CallHandler,
|
|
4
4
|
ExecutionContext,
|
|
5
5
|
mixin,
|
|
6
6
|
NestInterceptor,
|
|
7
7
|
Type,
|
|
8
|
-
} from
|
|
8
|
+
} from "@nestjs/common";
|
|
9
9
|
|
|
10
|
-
import { getMultipartRequest } from
|
|
11
|
-
import { transformUploadOptions, UploadOptions } from
|
|
10
|
+
import { getMultipartRequest } from "../multipart/request";
|
|
11
|
+
import { transformUploadOptions, UploadOptions } from "../multipart/options";
|
|
12
12
|
import {
|
|
13
13
|
handleMultipartFileFields,
|
|
14
14
|
UploadField,
|
|
15
15
|
UploadFieldMapEntry,
|
|
16
16
|
uploadFieldsToMap,
|
|
17
|
-
} from
|
|
17
|
+
} from "../multipart/handlers/file-fields";
|
|
18
18
|
|
|
19
19
|
export function FileFieldsInterceptor(
|
|
20
20
|
uploadFields: UploadField[],
|
|
21
|
-
options?: UploadOptions
|
|
21
|
+
options?: UploadOptions
|
|
22
22
|
): Type<NestInterceptor> {
|
|
23
23
|
class MixinInterceptor implements NestInterceptor {
|
|
24
24
|
private readonly options: UploadOptions;
|
|
@@ -32,15 +32,19 @@ export function FileFieldsInterceptor(
|
|
|
32
32
|
|
|
33
33
|
async intercept(
|
|
34
34
|
context: ExecutionContext,
|
|
35
|
-
next: CallHandler
|
|
35
|
+
next: CallHandler
|
|
36
36
|
): Promise<Observable<any>> {
|
|
37
37
|
const ctx = context.switchToHttp();
|
|
38
38
|
const req = getMultipartRequest(ctx);
|
|
39
39
|
|
|
40
|
+
if (!req.header("content-type")?.startsWith("multipart/form-data")) {
|
|
41
|
+
return next.handle();
|
|
42
|
+
}
|
|
43
|
+
|
|
40
44
|
const { body, files, remove } = await handleMultipartFileFields(
|
|
41
45
|
req,
|
|
42
46
|
this.fieldsMap,
|
|
43
|
-
this.options
|
|
47
|
+
this.options
|
|
44
48
|
);
|
|
45
49
|
|
|
46
50
|
req.body = body;
|
|
@@ -1,19 +1,19 @@
|
|
|
1
|
-
import { Observable, tap } from
|
|
1
|
+
import { Observable, tap } from "rxjs";
|
|
2
2
|
import {
|
|
3
3
|
CallHandler,
|
|
4
4
|
ExecutionContext,
|
|
5
5
|
mixin,
|
|
6
6
|
NestInterceptor,
|
|
7
7
|
Type,
|
|
8
|
-
} from
|
|
8
|
+
} from "@nestjs/common";
|
|
9
9
|
|
|
10
|
-
import { getMultipartRequest } from
|
|
11
|
-
import { transformUploadOptions, UploadOptions } from
|
|
12
|
-
import { handleMultipartSingleFile } from
|
|
10
|
+
import { getMultipartRequest } from "../multipart/request";
|
|
11
|
+
import { transformUploadOptions, UploadOptions } from "../multipart/options";
|
|
12
|
+
import { handleMultipartSingleFile } from "../multipart/handlers/single-file";
|
|
13
13
|
|
|
14
14
|
export function FileInterceptor(
|
|
15
15
|
fieldname: string,
|
|
16
|
-
options?: UploadOptions
|
|
16
|
+
options?: UploadOptions
|
|
17
17
|
): Type<NestInterceptor> {
|
|
18
18
|
class MixinInterceptor implements NestInterceptor {
|
|
19
19
|
private readonly options: UploadOptions;
|
|
@@ -24,15 +24,19 @@ export function FileInterceptor(
|
|
|
24
24
|
|
|
25
25
|
async intercept(
|
|
26
26
|
context: ExecutionContext,
|
|
27
|
-
next: CallHandler
|
|
27
|
+
next: CallHandler
|
|
28
28
|
): Promise<Observable<any>> {
|
|
29
29
|
const ctx = context.switchToHttp();
|
|
30
30
|
const req = getMultipartRequest(ctx);
|
|
31
31
|
|
|
32
|
+
if (!req.header("content-type")?.startsWith("multipart/form-data")) {
|
|
33
|
+
return next.handle();
|
|
34
|
+
}
|
|
35
|
+
|
|
32
36
|
const { file, body, remove } = await handleMultipartSingleFile(
|
|
33
37
|
req,
|
|
34
38
|
fieldname,
|
|
35
|
-
this.options
|
|
39
|
+
this.options
|
|
36
40
|
);
|
|
37
41
|
|
|
38
42
|
req.body = body;
|
|
@@ -1,20 +1,20 @@
|
|
|
1
|
-
import { Observable, tap } from
|
|
1
|
+
import { Observable, tap } from "rxjs";
|
|
2
2
|
import {
|
|
3
3
|
CallHandler,
|
|
4
4
|
ExecutionContext,
|
|
5
5
|
mixin,
|
|
6
6
|
NestInterceptor,
|
|
7
7
|
Type,
|
|
8
|
-
} from
|
|
8
|
+
} from "@nestjs/common";
|
|
9
9
|
|
|
10
|
-
import { getMultipartRequest } from
|
|
11
|
-
import { transformUploadOptions, UploadOptions } from
|
|
12
|
-
import { handleMultipartMultipleFiles } from
|
|
10
|
+
import { getMultipartRequest } from "../multipart/request";
|
|
11
|
+
import { transformUploadOptions, UploadOptions } from "../multipart/options";
|
|
12
|
+
import { handleMultipartMultipleFiles } from "../multipart/handlers/multiple-files";
|
|
13
13
|
|
|
14
14
|
export function FilesInterceptor(
|
|
15
15
|
fieldname: string,
|
|
16
16
|
maxCount = 1,
|
|
17
|
-
options?: UploadOptions
|
|
17
|
+
options?: UploadOptions
|
|
18
18
|
): Type<NestInterceptor> {
|
|
19
19
|
class MixinInterceptor implements NestInterceptor {
|
|
20
20
|
private readonly options: UploadOptions;
|
|
@@ -25,16 +25,20 @@ export function FilesInterceptor(
|
|
|
25
25
|
|
|
26
26
|
async intercept(
|
|
27
27
|
context: ExecutionContext,
|
|
28
|
-
next: CallHandler
|
|
28
|
+
next: CallHandler
|
|
29
29
|
): Promise<Observable<any>> {
|
|
30
30
|
const ctx = context.switchToHttp();
|
|
31
31
|
const req = getMultipartRequest(ctx);
|
|
32
32
|
|
|
33
|
+
if (!req.header("content-type")?.startsWith("multipart/form-data")) {
|
|
34
|
+
return next.handle();
|
|
35
|
+
}
|
|
36
|
+
|
|
33
37
|
const { body, files, remove } = await handleMultipartMultipleFiles(
|
|
34
38
|
req,
|
|
35
39
|
fieldname,
|
|
36
40
|
maxCount,
|
|
37
|
-
this.options
|
|
41
|
+
this.options
|
|
38
42
|
);
|
|
39
43
|
|
|
40
44
|
req.body = body;
|
|
@@ -16,10 +16,6 @@ export type THonoRequest = HonoRequest & {
|
|
|
16
16
|
export const getMultipartRequest = (ctx: HttpArgumentsHost) => {
|
|
17
17
|
const req = ctx.getRequest<THonoRequest>();
|
|
18
18
|
|
|
19
|
-
if (!req.header("content-type")?.startsWith("multipart/form-data")) {
|
|
20
|
-
// throw new BadRequestException("Not a multipart request");
|
|
21
|
-
}
|
|
22
|
-
|
|
23
19
|
return req;
|
|
24
20
|
};
|
|
25
21
|
|