damex 2.0.0 → 2.0.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/README.md ADDED
@@ -0,0 +1,59 @@
1
+ ## Decorators
2
+
3
+ ### Used in Classes
4
+
5
+ ```typescript
6
+ @Controller
7
+ ```
8
+
9
+ Receives a string indicating the route of the controller.
10
+
11
+ ```typescript
12
+ @GlobalMiddleware
13
+ ```
14
+
15
+ Receives an array with all the middleware methods that will be applied to all the methods of the controller.
16
+
17
+ ### Used in Methods
18
+
19
+ ```typescript
20
+ @Get - path: string
21
+ @Post - path: string
22
+ @Put - path: string
23
+ @Patch - path: string
24
+ @Delete - path: string
25
+ @Middleware - Array with methods
26
+ ```
27
+
28
+ #### Example
29
+
30
+ ```typescript
31
+ @Controller('/users')
32
+ @GlobalMiddleware([auth])
33
+ export class UsersController {
34
+ constructor() {}
35
+
36
+ @Get()
37
+ @Middleware([logger])
38
+ getAll(req: Request, res: Response) {
39
+ res.status(200).send([
40
+ { id: 1, user: 'admin' },
41
+ { id: 2, user: 'default' },
42
+ ]);
43
+ }
44
+
45
+ @Get('/:id')
46
+ @Middleware([anotherLogger])
47
+ getById(req: Request, res: Response) {
48
+ console.log('request accepted...');
49
+
50
+ res.status(200).send([
51
+ { id: 1, user: 'admin' },
52
+ { id: 2, user: 'default' },
53
+ ]);
54
+ }
55
+ }
56
+ ```
57
+
58
+ # Warning!
59
+ This package doesn't work with dependency injection for now. Because of this, and due to the way the routes are implemented, all services used inside controllers or other services must implement as static methods.