@kiyasov/platform-hono 1.5.3 → 1.5.5

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.
@@ -0,0 +1,9 @@
1
+ {
2
+ "permissions": {
3
+ "allow": [
4
+ "Bash(bun run build:esm:*)"
5
+ ],
6
+ "deny": [],
7
+ "ask": []
8
+ }
9
+ }
package/Readme.md CHANGED
@@ -1,40 +1,55 @@
1
- # Hono NestJS Adapter
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)
3
+ <div align="center">
5
4
 
6
- This package allows you to use Hono with the NestJS framework.
5
+ [![NPM version](https://img.shields.io/npm/v/@kiyasov/platform-hono.svg?style=flat-square)](https://www.npmjs.com/package/@kiyasov/platform-hono)
6
+ [![NPM Downloads](https://img.shields.io/npm/dm/@kiyasov/platform-hono.svg?style=flat-square)](https://www.npmjs.com/package/@kiyasov/platform-hono)
7
+ [![License](https://img.shields.io/npm/l/@kiyasov/platform-hono.svg?style=flat-square)](https://github.com/kiyasov/platform-hono/blob/main/LICENSE)
7
8
 
8
- ## Components
9
+ **Use [Hono](https://hono.dev/) with [NestJS](https://nestjs.com/)**
9
10
 
10
- - `HonoAdapter`: Adapter to use Hono with NestJS.
11
+ </div>
11
12
 
12
- ## How to Use
13
+ ---
13
14
 
14
- ### Setup
15
+ ## 📦 Installation
15
16
 
16
- To install [`@kiyasov/platform-hono`](https://www.npmjs.com/package/@kiyasov/platform-hono):
17
-
18
- ```shell
17
+ ```bash
19
18
  npm install @kiyasov/platform-hono
20
- # or
19
+ ```
20
+
21
+ ```bash
21
22
  yarn add @kiyasov/platform-hono
22
23
  ```
23
24
 
24
- ### Create Application
25
+ ```bash
26
+ pnpm add @kiyasov/platform-hono
27
+ ```
28
+
29
+ ```bash
30
+ bun add @kiyasov/platform-hono
31
+ ```
32
+
33
+ ## ⚡ Quick Start
25
34
 
26
35
  ```typescript
27
- import { NestFactory } from "@nestjs/core";
28
- import { AppModule } from "./app.module";
29
- import { HonoAdapter } from "@kiyasov/platform-hono";
30
-
31
- const app = await NestFactory.create<NestHonoApplication>(
32
- AppModule,
33
- new HonoAdapter()
34
- );
36
+ import { NestFactory } from '@nestjs/core';
37
+ import { HonoAdapter } from '@kiyasov/platform-hono';
38
+ import { AppModule } from './app.module';
39
+
40
+ async function bootstrap() {
41
+ const app = await NestFactory.create(AppModule, new HonoAdapter());
42
+
43
+ await app.listen(3000);
44
+ console.log(`Application is running on: ${await app.getUrl()}`);
45
+ }
46
+
47
+ bootstrap();
35
48
  ```
36
49
 
37
- ### Exception filters
50
+ ## 🎯 Usage Examples
51
+
52
+ ### Exception Filter with HonoAdapter
38
53
 
39
54
  ```typescript
40
55
  import {
@@ -43,8 +58,8 @@ import {
43
58
  ArgumentsHost,
44
59
  HttpException,
45
60
  HttpStatus,
46
- } from "@nestjs/common";
47
- import { HttpAdapterHost } from "@nestjs/core";
61
+ } from '@nestjs/common';
62
+ import { HttpAdapterHost } from '@nestjs/core';
48
63
 
49
64
  @Catch()
50
65
  export class AllExceptionsFilter implements ExceptionFilter {
@@ -52,7 +67,6 @@ export class AllExceptionsFilter implements ExceptionFilter {
52
67
 
53
68
  catch(exception: unknown, host: ArgumentsHost): void {
54
69
  const { httpAdapter } = this.httpAdapterHost;
55
-
56
70
  const ctx = host.switchToHttp();
57
71
 
58
72
  const httpStatus =
@@ -70,3 +84,22 @@ export class AllExceptionsFilter implements ExceptionFilter {
70
84
  }
71
85
  }
72
86
  ```
87
+
88
+ ## 📚 Documentation
89
+
90
+ For more examples and detailed documentation, check out the [example](./example) directory.
91
+
92
+ ## 🤝 Contributing
93
+
94
+ Contributions are welcome! Please feel free to submit a Pull Request.
95
+
96
+ ## 📄 License
97
+
98
+ MIT © [Islam Kiiasov](https://github.com/kiyasov)
99
+
100
+ ## 🔗 Links
101
+
102
+ - [NPM Package](https://www.npmjs.com/package/@kiyasov/platform-hono)
103
+ - [GitHub Repository](https://github.com/kiyasov/platform-hono)
104
+ - [Hono Framework](https://hono.dev/)
105
+ - [NestJS Framework](https://nestjs.com/)
@@ -1,9 +1,9 @@
1
- import autocannon from "autocannon";
2
- import { PassThrough } from "stream";
1
+ import autocannon from 'autocannon';
2
+ import { PassThrough } from 'stream';
3
3
 
4
4
  // Example base64-encoded image (black square 100x100 pixels)
5
5
  const base64Content =
6
- "iVBORw0KGgoAAAANSUhEUgAAAGQAAABkCAIAAAD/gAIDAAAABmJLR0QA/wD/AP+gvaeTAAAAJ0lEQVR4nO3BAQEAAACCIP+vbkhAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAwH8GAAF3Xq9HAAAAAElFTkSuQmCC";
6
+ 'iVBORw0KGgoAAAANSUhEUgAAAGQAAABkCAIAAAD/gAIDAAAABmJLR0QA/wD/AP+gvaeTAAAAJ0lEQVR4nO3BAQEAAACCIP+vbkhAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAwH8GAAF3Xq9HAAAAAElFTkSuQmCC';
7
7
 
8
8
  // Create the request body with the base64 string
9
9
  const formData = `--boundary
@@ -15,8 +15,8 @@ ${base64Content}
15
15
 
16
16
  // Set up headers
17
17
  const headers = {
18
- "Content-Type": "multipart/form-data; boundary=boundary",
19
- "Content-Length": Buffer.byteLength(formData),
18
+ 'Content-Type': 'multipart/form-data; boundary=boundary',
19
+ 'Content-Length': Buffer.byteLength(formData),
20
20
  };
21
21
 
22
22
  const pass = new PassThrough();
@@ -24,12 +24,12 @@ pass.end(formData);
24
24
 
25
25
  const chunks = [];
26
26
 
27
- pass.on("data", (chunk) => chunks.push(chunk));
28
- pass.on("end", () => {
27
+ pass.on('data', (chunk) => chunks.push(chunk));
28
+ pass.on('end', () => {
29
29
  const formBuffer = Buffer.concat(chunks);
30
30
  const instance = autocannon({
31
- url: "http://localhost:3000/uploadFile",
32
- method: "POST",
31
+ url: 'http://localhost:3000/uploadFile',
32
+ method: 'POST',
33
33
  headers: headers,
34
34
  body: formBuffer,
35
35
  connections: 200,
@@ -39,13 +39,13 @@ pass.on("end", () => {
39
39
 
40
40
  autocannon.track(instance, { renderProgressBar: true });
41
41
 
42
- process.once("SIGINT", () => {
42
+ process.once('SIGINT', () => {
43
43
  instance.stop();
44
44
  });
45
45
  });
46
46
 
47
- pass.on("error", (err) => {
48
- console.error("Error reading data from the stream", err);
47
+ pass.on('error', (err) => {
48
+ console.error('Error reading data from the stream', err);
49
49
  });
50
50
 
51
51
  pass.resume();
@@ -12,7 +12,7 @@ export declare class MemoryStorage implements Storage<MemoryStorageFile> {
12
12
  mimetype: string;
13
13
  fieldname: string;
14
14
  originalFilename: string;
15
- stream: () => ReadableStream<Uint8Array<ArrayBufferLike>>;
15
+ stream: () => ReadableStream<Uint8Array<ArrayBuffer>>;
16
16
  lastModified: number;
17
17
  }>;
18
18
  removeFile(file: MemoryStorageFile): Promise<void>;