@kiyasov/platform-hono 1.1.1 → 1.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.
Binary file
package/Readme.md CHANGED
@@ -1,5 +1,8 @@
1
1
  # Hono NestJS Adapter
2
2
 
3
+ [![NPM version](https://badge.fury.io/js/@kiyasov%2Fplatform-hono.svg)](https://www.npmjs.com/package/@kiyasov/platform-hono)
4
+ [![NPM Downloads](https://img.shields.io/npm/dw/%40kiyasov%2Fplatform-hono)](https://www.npmjs.com/package/@kiyasov/platform-hono)
5
+
3
6
  This package allows you to use Hono with the NestJS framework.
4
7
 
5
8
  ## Components
@@ -8,12 +11,22 @@ This package allows you to use Hono with the NestJS framework.
8
11
 
9
12
  ## How to Use
10
13
 
14
+ ### Setup
15
+
16
+ To install [`@kiyasov/platform-hono`](https://www.npmjs.com/package/@kiyasov/platform-hono):
17
+
18
+ ```shell
19
+ npm install @kiyasov/platform-hono
20
+ # or
21
+ yarn add @kiyasov/platform-hono
22
+ ```
23
+
11
24
  ### Create Application
12
25
 
13
26
  ```typescript
14
27
  import { NestFactory } from "@nestjs/core";
15
28
  import { AppModule } from "./app.module";
16
- import { HonoAdapter } from "./hono.adapter";
29
+ import { HonoAdapter } from "@kiyasov/platform-hono";
17
30
 
18
31
  const app = await NestFactory.create<NestHonoApplication>(
19
32
  AppModule,
@@ -0,0 +1,51 @@
1
+ import autocannon from "autocannon";
2
+ import { PassThrough } from "stream";
3
+
4
+ // Example base64-encoded image (black square 100x100 pixels)
5
+ const base64Content =
6
+ "iVBORw0KGgoAAAANSUhEUgAAAGQAAABkCAIAAAD/gAIDAAAABmJLR0QA/wD/AP+gvaeTAAAAJ0lEQVR4nO3BAQEAAACCIP+vbkhAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAwH8GAAF3Xq9HAAAAAElFTkSuQmCC";
7
+
8
+ // Create the request body with the base64 string
9
+ const formData = `--boundary
10
+ Content-Disposition: form-data; name="file"; filename="square.png"
11
+ Content-Type: image/png
12
+
13
+ ${base64Content}
14
+ --boundary--`;
15
+
16
+ // Set up headers
17
+ const headers = {
18
+ "Content-Type": "multipart/form-data; boundary=boundary",
19
+ "Content-Length": Buffer.byteLength(formData),
20
+ };
21
+
22
+ const pass = new PassThrough();
23
+ pass.end(formData);
24
+
25
+ const chunks = [];
26
+
27
+ pass.on("data", (chunk) => chunks.push(chunk));
28
+ pass.on("end", () => {
29
+ const formBuffer = Buffer.concat(chunks);
30
+ const instance = autocannon({
31
+ url: "http://localhost:3000/uploadFile",
32
+ method: "POST",
33
+ headers: headers,
34
+ body: formBuffer,
35
+ connections: 200,
36
+ duration: 5,
37
+ pipelining: 10,
38
+ });
39
+
40
+ autocannon.track(instance, { renderProgressBar: true });
41
+
42
+ process.once("SIGINT", () => {
43
+ instance.stop();
44
+ });
45
+ });
46
+
47
+ pass.on("error", (err) => {
48
+ console.error("Error reading data from the stream", err);
49
+ });
50
+
51
+ pass.resume();
package/bun.lockb ADDED
Binary file