quantum-flow 1.1.0 → 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.
package/README.md CHANGED
@@ -16,12 +16,71 @@ yarn build
16
16
 
17
17
  # Usage
18
18
 
19
+ You can use controllers and server functionality by importing controllers and creating server instances as shown in the examples above. Use your preferred testing framework to write unit and integration tests.
20
+
21
+ # Project Structure
22
+
23
+ - `quantum-flow/http` - Main application source code for HTTP servers.
24
+ - `quantum-flow/aws` - Main application source code AWS Lambda.
25
+ - `quantum-flow/core` - Core framework components like Controller and Endpoint.
26
+
27
+ ---
28
+
19
29
  ## Defining Controllers
20
30
 
21
31
  Use the `@Controller` decorator to define controllers with options such as prefix, sub-controllers, middlewares, and interceptors.
22
32
 
23
33
  ```typescript
24
- import { Controller } from 'quantum-flow/core';
34
+ import {
35
+ Body,
36
+ Catch,
37
+ Controller,
38
+ Headers,
39
+ InjectWS,
40
+ IWebSocketService,
41
+ Params,
42
+ PUT,
43
+ Query,
44
+ Request,
45
+ Response,
46
+ Status,
47
+ USE
48
+ } from 'quantum-flow/core';
49
+ import {IsString} from 'class-validator'
50
+
51
+ class UserDto {
52
+ constructor() {}
53
+ @IsString()
54
+ name: string;
55
+ }
56
+
57
+ @Controller({
58
+ prefix: 'user',
59
+ controllers: [UserMetadata, ...],
60
+ interceptor: (data, req, res) => {
61
+ return { data, intercepted: true };
62
+ },
63
+ })
64
+ @Catch((err) => ({ status: 500, err }))
65
+ export class User {
66
+ @Status(201)
67
+ @PUT(':id')
68
+ async createUser(
69
+ @Body(UserDto) body: UserDto,
70
+ @Query() query: any,
71
+ @Headers() headers: any,
72
+ @Params() params: any,
73
+ @Request() req: any,
74
+ @Response() resp: any,
75
+ @InjectWS() ws: IWebSocketService,
76
+ ) {
77
+ }
78
+
79
+ @USE()
80
+ async any(@Response() resp: any) {
81
+ ...
82
+ }
83
+ }
25
84
 
26
85
  @Controller(api, [...middlewares])
27
86
  @Controller({
@@ -34,7 +93,7 @@ import { Controller } from 'quantum-flow/core';
34
93
  class RootController {}
35
94
  ```
36
95
 
37
- ## Creating a Server
96
+ ## Creating a http Server
38
97
 
39
98
  Use the `@Server` decorator with configuration options like port, host, controllers, and WebSocket enablement.
40
99
 
@@ -180,44 +239,8 @@ export class Socket {
180
239
  }
181
240
  ```
182
241
 
183
- # Http server configuration
184
-
185
- ```typescript
186
- @Server({
187
- controllers: [Root],
188
- websocket: { enabled: true },
189
- interceptor: (data) => data,
190
- })
191
- @Port(3000)
192
- @Use((data) => data)
193
- @Use((data) => data)
194
- @Catch((error) => ({ status: 400, error }))
195
- class App {}
196
- ```
197
-
198
- # Usage
199
-
200
- You can use controllers and server functionality by importing controllers and creating server instances as shown in the examples above. Use your preferred testing framework to write unit and integration tests.
201
-
202
- # Project Structure
203
-
204
- - `quantum-flow/http` - Main application source code for HTTP servers.
205
- - `quantum-flow/aws` - Main application source code AWS Lambda.
206
- - `quantum-flow/core` - Core framework components like Controller and Endpoint.
207
-
208
- ---
209
-
210
242
  # Decorators
211
243
 
212
- ### Server
213
-
214
- Class decorator to configure the server with options like controllers, global middlewares, and interceptors.
215
-
216
- ```typescript
217
- @Server({ controllers: [RootController] })
218
- class App {}
219
- ```
220
-
221
244
  ### Use
222
245
 
223
246
  Class decorator to add global middlewares to the server.
@@ -26,7 +26,6 @@ function Endpoint(method, pathPattern, middlewares) {
26
26
  console.warn('❌ originalMethod is undefined!');
27
27
  return descriptor;
28
28
  }
29
- console.log(pathPattern);
30
29
  if (method && pathPattern) {
31
30
  Reflect.defineMetadata(_constants_1.ENDPOINT, [method, pathPattern], target, propertyKey);
32
31
  Reflect.defineMetadata('middlewares', middlewares || [], target, propertyKey);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "quantum-flow",
3
- "version": "1.1.0",
3
+ "version": "1.1.2",
4
4
  "description": "Decorator-based API framework",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",