damex 1.1.6 → 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.
Files changed (47) hide show
  1. package/README.md +52 -8
  2. package/index.js +373 -0
  3. package/package.json +9 -6
  4. package/.prettierrc +0 -5
  5. package/lib/classes/AppRouter.d.ts +0 -4
  6. package/lib/classes/AppRouter.js +0 -11
  7. package/lib/classes/Server.d.ts +0 -9
  8. package/lib/classes/Server.js +0 -36
  9. package/lib/classes/index.d.ts +0 -2
  10. package/lib/classes/index.js +0 -18
  11. package/lib/decorators/controller.decorator.d.ts +0 -1
  12. package/lib/decorators/controller.decorator.js +0 -21
  13. package/lib/decorators/global-middleware.decorator.d.ts +0 -2
  14. package/lib/decorators/global-middleware.decorator.js +0 -9
  15. package/lib/decorators/http-methods.decorator.d.ts +0 -5
  16. package/lib/decorators/http-methods.decorator.js +0 -17
  17. package/lib/decorators/index.d.ts +0 -4
  18. package/lib/decorators/index.js +0 -20
  19. package/lib/decorators/middleware.decorator.d.ts +0 -2
  20. package/lib/decorators/middleware.decorator.js +0 -9
  21. package/lib/index.d.ts +0 -4
  22. package/lib/index.js +0 -20
  23. package/lib/types/enums/ControllerMethodsParams.d.ts +0 -6
  24. package/lib/types/enums/ControllerMethodsParams.js +0 -10
  25. package/lib/types/enums/HttpMethods.d.ts +0 -7
  26. package/lib/types/enums/HttpMethods.js +0 -11
  27. package/lib/types/enums/ServerConfigsParams.d.ts +0 -4
  28. package/lib/types/enums/ServerConfigsParams.js +0 -8
  29. package/lib/types/enums/index.d.ts +0 -3
  30. package/lib/types/enums/index.js +0 -19
  31. package/lib/types/index.d.ts +0 -1
  32. package/lib/types/index.js +0 -17
  33. package/src/classes/AppRouter.ts +0 -9
  34. package/src/classes/Server.ts +0 -43
  35. package/src/classes/index.ts +0 -2
  36. package/src/decorators/controller.decorator.ts +0 -45
  37. package/src/decorators/global-middleware.decorator.ts +0 -12
  38. package/src/decorators/http-methods.decorator.ts +0 -26
  39. package/src/decorators/index.ts +0 -4
  40. package/src/decorators/middleware.decorator.ts +0 -13
  41. package/src/index.ts +0 -5
  42. package/src/types/enums/ControllerMethodsParams.ts +0 -6
  43. package/src/types/enums/HttpMethods.ts +0 -7
  44. package/src/types/enums/ServerConfigsParams.ts +0 -4
  45. package/src/types/enums/index.ts +0 -3
  46. package/src/types/index.ts +0 -1
  47. package/tsconfig.json +0 -17
package/README.md CHANGED
@@ -1,15 +1,59 @@
1
- # dexpress
1
+ ## Decorators
2
2
 
3
- To install dependencies:
3
+ ### Used in Classes
4
4
 
5
- ```bash
6
- bun install
5
+ ```typescript
6
+ @Controller
7
7
  ```
8
8
 
9
- To run:
9
+ Receives a string indicating the route of the controller.
10
10
 
11
- ```bash
12
- bun run src/server.ts
11
+ ```typescript
12
+ @GlobalMiddleware
13
13
  ```
14
14
 
15
- This project was created using `bun init` in bun v1.2.1. [Bun](https://bun.sh) is a fast all-in-one JavaScript runtime.
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.