@kiyasov/platform-hono 1.3.20 → 1.4.1
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/.yarn/install-state.gz +0 -0
- package/dist/cjs/src/multer/interceptors/any-files-interceptor.js +1 -1
- package/dist/cjs/src/multer/interceptors/any-files-interceptor.js.map +1 -1
- package/dist/cjs/src/multer/interceptors/file-fields-interceptor.js +1 -1
- package/dist/cjs/src/multer/interceptors/file-fields-interceptor.js.map +1 -1
- package/dist/cjs/src/multer/interceptors/file-interceptor.js +1 -1
- package/dist/cjs/src/multer/interceptors/file-interceptor.js.map +1 -1
- package/dist/cjs/src/multer/interceptors/files-interceptor.js +1 -1
- package/dist/cjs/src/multer/interceptors/files-interceptor.js.map +1 -1
- package/dist/cjs/src/multer/storage/disk-storage.d.ts +2 -2
- package/dist/cjs/src/multer/storage/disk-storage.js +4 -4
- package/dist/cjs/src/multer/storage/disk-storage.js.map +1 -1
- package/dist/cjs/src/multer/storage/memory-storage.d.ts +5 -2
- package/dist/cjs/src/multer/storage/memory-storage.js +8 -2
- package/dist/cjs/src/multer/storage/memory-storage.js.map +1 -1
- package/dist/cjs/tsconfig.cjs.tsbuildinfo +1 -1
- package/dist/esm/src/multer/interceptors/any-files-interceptor.js +2 -2
- package/dist/esm/src/multer/interceptors/any-files-interceptor.js.map +1 -1
- package/dist/esm/src/multer/interceptors/file-fields-interceptor.js +2 -2
- package/dist/esm/src/multer/interceptors/file-fields-interceptor.js.map +1 -1
- package/dist/esm/src/multer/interceptors/file-interceptor.js +2 -2
- package/dist/esm/src/multer/interceptors/file-interceptor.js.map +1 -1
- package/dist/esm/src/multer/interceptors/files-interceptor.js +2 -2
- package/dist/esm/src/multer/interceptors/files-interceptor.js.map +1 -1
- package/dist/esm/src/multer/storage/disk-storage.d.ts +2 -2
- package/dist/esm/src/multer/storage/disk-storage.js +10 -10
- package/dist/esm/src/multer/storage/disk-storage.js.map +1 -1
- package/dist/esm/src/multer/storage/memory-storage.d.ts +5 -2
- package/dist/esm/src/multer/storage/memory-storage.js +8 -2
- package/dist/esm/src/multer/storage/memory-storage.js.map +1 -1
- package/dist/esm/tsconfig.esm.tsbuildinfo +1 -1
- package/package.json +5 -5
- package/src/multer/interceptors/any-files-interceptor.ts +2 -2
- package/src/multer/interceptors/file-fields-interceptor.ts +2 -2
- package/src/multer/interceptors/file-interceptor.ts +2 -2
- package/src/multer/interceptors/files-interceptor.ts +2 -2
- package/src/multer/storage/disk-storage.ts +15 -15
- package/src/multer/storage/memory-storage.ts +11 -4
- package/bun.lockb +0 -0
- package/src/multer/stream/index.ts +0 -4
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kiyasov/platform-hono",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.4.1",
|
|
4
4
|
"description": "Nest adapter for Hono",
|
|
5
5
|
"author": "Islam Kiiasov",
|
|
6
6
|
"repository": {
|
|
@@ -32,14 +32,14 @@
|
|
|
32
32
|
"@hono/node-server": "^1.13.8",
|
|
33
33
|
"@nestjs/apollo": "^13.0.2",
|
|
34
34
|
"@nestjs/graphql": "^13.0.2",
|
|
35
|
-
"hono": "^4.7.
|
|
35
|
+
"hono": "^4.7.1"
|
|
36
36
|
},
|
|
37
37
|
"devDependencies": {
|
|
38
38
|
"@nestjs/cli": "^11.0.2",
|
|
39
|
-
"@nestjs/common": "^11.0.
|
|
40
|
-
"@nestjs/core": "^11.0.
|
|
39
|
+
"@nestjs/common": "^11.0.9",
|
|
40
|
+
"@nestjs/core": "^11.0.9",
|
|
41
41
|
"@swc/cli": "^0.6.0",
|
|
42
|
-
"@swc/core": "^1.10.
|
|
42
|
+
"@swc/core": "^1.10.16",
|
|
43
43
|
"@types/autocannon": "^7.12.6",
|
|
44
44
|
"@types/bun": "^1.2.2",
|
|
45
45
|
"@types/busboy": "^1.5.4",
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { finalize, Observable } from "rxjs";
|
|
2
2
|
import {
|
|
3
3
|
CallHandler,
|
|
4
4
|
ExecutionContext,
|
|
@@ -40,7 +40,7 @@ export function AnyFilesInterceptor(
|
|
|
40
40
|
req.body = body;
|
|
41
41
|
req.storageFiles = files;
|
|
42
42
|
|
|
43
|
-
return next.handle().pipe(
|
|
43
|
+
return next.handle().pipe(finalize(remove));
|
|
44
44
|
}
|
|
45
45
|
}
|
|
46
46
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { finalize, Observable } from "rxjs";
|
|
2
2
|
import {
|
|
3
3
|
CallHandler,
|
|
4
4
|
ExecutionContext,
|
|
@@ -50,7 +50,7 @@ export function FileFieldsInterceptor(
|
|
|
50
50
|
req.body = body;
|
|
51
51
|
req.storageFiles = files;
|
|
52
52
|
|
|
53
|
-
return next.handle().pipe(
|
|
53
|
+
return next.handle().pipe(finalize(remove));
|
|
54
54
|
}
|
|
55
55
|
}
|
|
56
56
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { finalize, Observable } from "rxjs";
|
|
2
2
|
import {
|
|
3
3
|
CallHandler,
|
|
4
4
|
ExecutionContext,
|
|
@@ -42,7 +42,7 @@ export function FileInterceptor(
|
|
|
42
42
|
req.body = body;
|
|
43
43
|
req.storageFile = file;
|
|
44
44
|
|
|
45
|
-
return next.handle().pipe(
|
|
45
|
+
return next.handle().pipe(finalize(remove));
|
|
46
46
|
}
|
|
47
47
|
}
|
|
48
48
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { finalize, Observable } from "rxjs";
|
|
2
2
|
import {
|
|
3
3
|
CallHandler,
|
|
4
4
|
ExecutionContext,
|
|
@@ -44,7 +44,7 @@ export function FilesInterceptor(
|
|
|
44
44
|
req.body = body;
|
|
45
45
|
req.storageFiles = files;
|
|
46
46
|
|
|
47
|
-
return next.handle().pipe(
|
|
47
|
+
return next.handle().pipe(finalize(remove));
|
|
48
48
|
}
|
|
49
49
|
}
|
|
50
50
|
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import { tmpdir } from
|
|
2
|
-
import { createWriteStream } from
|
|
3
|
-
import { mkdir, unlink } from
|
|
4
|
-
import { join } from
|
|
1
|
+
import { tmpdir } from "os";
|
|
2
|
+
import { createWriteStream } from "fs";
|
|
3
|
+
import { mkdir, unlink } from "fs/promises";
|
|
4
|
+
import { join } from "path";
|
|
5
5
|
|
|
6
|
-
import { StorageFile, Storage } from
|
|
7
|
-
import { getUniqueFilename, pathExists } from
|
|
8
|
-
import {
|
|
9
|
-
import { HonoRequest } from
|
|
10
|
-
import { Readable } from
|
|
6
|
+
import { StorageFile, Storage } from "./storage";
|
|
7
|
+
import { getUniqueFilename, pathExists } from "../fs";
|
|
8
|
+
import { pipeline } from "node:stream/promises";
|
|
9
|
+
import { HonoRequest } from "hono";
|
|
10
|
+
import { Readable } from "node:stream";
|
|
11
11
|
|
|
12
12
|
export interface DiskStorageFile extends StorageFile {
|
|
13
13
|
dest: string;
|
|
@@ -28,9 +28,9 @@ export interface DiskStorageOptions {
|
|
|
28
28
|
const excecuteStorageHandler = (
|
|
29
29
|
file: File,
|
|
30
30
|
req: HonoRequest,
|
|
31
|
-
obj?: DiskStorageOptionHandler
|
|
31
|
+
obj?: DiskStorageOptionHandler
|
|
32
32
|
) => {
|
|
33
|
-
if (typeof obj ===
|
|
33
|
+
if (typeof obj === "function") {
|
|
34
34
|
return obj(file, req);
|
|
35
35
|
}
|
|
36
36
|
|
|
@@ -67,7 +67,7 @@ export class DiskStorage
|
|
|
67
67
|
const buffer = await file.arrayBuffer();
|
|
68
68
|
const readableStream = Readable.from(Buffer.from(buffer));
|
|
69
69
|
|
|
70
|
-
await
|
|
70
|
+
await pipeline(readableStream, stream);
|
|
71
71
|
|
|
72
72
|
return {
|
|
73
73
|
size: stream.bytesWritten,
|
|
@@ -76,7 +76,7 @@ export class DiskStorage
|
|
|
76
76
|
originalFilename: file.name,
|
|
77
77
|
path,
|
|
78
78
|
mimetype: file.type,
|
|
79
|
-
encoding:
|
|
79
|
+
encoding: "utf-8",
|
|
80
80
|
fieldname: fieldName,
|
|
81
81
|
};
|
|
82
82
|
}
|
|
@@ -90,7 +90,7 @@ export class DiskStorage
|
|
|
90
90
|
protected async getFilename(
|
|
91
91
|
file: File,
|
|
92
92
|
req: HonoRequest,
|
|
93
|
-
obj?: DiskStorageOptionHandler
|
|
93
|
+
obj?: DiskStorageOptionHandler
|
|
94
94
|
): Promise<string> {
|
|
95
95
|
return (
|
|
96
96
|
excecuteStorageHandler(file, req, obj) ?? getUniqueFilename(file.name)
|
|
@@ -100,7 +100,7 @@ export class DiskStorage
|
|
|
100
100
|
protected async getFileDestination(
|
|
101
101
|
file: File,
|
|
102
102
|
req: HonoRequest,
|
|
103
|
-
obj?: DiskStorageOptionHandler
|
|
103
|
+
obj?: DiskStorageOptionHandler
|
|
104
104
|
): Promise<string> {
|
|
105
105
|
return excecuteStorageHandler(file, req, obj) ?? tmpdir();
|
|
106
106
|
}
|
|
@@ -1,21 +1,28 @@
|
|
|
1
|
-
import { StorageFile, Storage } from
|
|
2
|
-
import { HonoRequest } from
|
|
1
|
+
import { StorageFile, Storage } from "./storage";
|
|
2
|
+
import { HonoRequest } from "hono";
|
|
3
3
|
|
|
4
4
|
export interface MemoryStorageFile extends StorageFile {
|
|
5
5
|
buffer: Buffer;
|
|
6
|
+
stream: () => ReadableStream<Uint8Array>;
|
|
6
7
|
}
|
|
7
8
|
|
|
8
9
|
export class MemoryStorage implements Storage<MemoryStorageFile> {
|
|
9
10
|
public async handleFile(file: File, _req: HonoRequest, fieldName: string) {
|
|
10
|
-
const buffer = await file
|
|
11
|
+
const buffer = await file
|
|
12
|
+
.stream()
|
|
13
|
+
.pipeTo(new WritableStream())
|
|
14
|
+
.then(() => file.arrayBuffer())
|
|
15
|
+
.then((buffer) => Buffer.from(buffer));
|
|
11
16
|
|
|
12
17
|
return {
|
|
13
18
|
buffer,
|
|
14
19
|
size: buffer.length,
|
|
15
|
-
encoding:
|
|
20
|
+
encoding: "utf-8",
|
|
16
21
|
mimetype: file.type,
|
|
17
22
|
fieldname: fieldName,
|
|
18
23
|
originalFilename: file.name,
|
|
24
|
+
stream: () => file.stream(),
|
|
25
|
+
lastModified: file.lastModified,
|
|
19
26
|
};
|
|
20
27
|
}
|
|
21
28
|
|
package/bun.lockb
DELETED
|
Binary file
|