quantum-flow 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.
- package/README.md +50 -1
- package/dist/core/Endpoint.js +0 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -31,7 +31,56 @@ You can use controllers and server functionality by importing controllers and cr
|
|
|
31
31
|
Use the `@Controller` decorator to define controllers with options such as prefix, sub-controllers, middlewares, and interceptors.
|
|
32
32
|
|
|
33
33
|
```typescript
|
|
34
|
-
import {
|
|
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
|
+
}
|
|
35
84
|
|
|
36
85
|
@Controller(api, [...middlewares])
|
|
37
86
|
@Controller({
|
package/dist/core/Endpoint.js
CHANGED
|
@@ -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);
|