damex 2.0.0 → 2.0.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 ADDED
@@ -0,0 +1,58 @@
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
+
18
+ ```typescript
19
+ @Inject
20
+ ```
21
+ Used on classes that required DI. If the class Already has a decorator (as @Controller), the @Inject is not required.
22
+
23
+ ### Used in Methods
24
+
25
+ ```typescript
26
+ @Get - path: string
27
+ @Post - path: string
28
+ @Put - path: string
29
+ @Patch - path: string
30
+ @Delete - path: string
31
+ @Middleware - Array with methods
32
+ ```
33
+
34
+ #### Example
35
+
36
+ ```typescript
37
+ @Controller('/users')
38
+ @GlobalMiddleware([auth])
39
+ export class UsersController {
40
+ constructor(private userService: UserService) {}
41
+
42
+ @Get()
43
+ @Middleware([logger])
44
+ async getAll(req: Request, res: Response) {
45
+ const users = await this.userService.all()
46
+
47
+ res.status(200).send(users);
48
+ }
49
+
50
+ @Get('/:id')
51
+ @Middleware([anotherLogger])
52
+ async getById(req: Request, res: Response) {
53
+ const users = await this.userService.findById(req.params.id!)
54
+
55
+ res.status(200).send(users);
56
+ }
57
+ }
58
+ ```