@hedhog/admin 0.46.35 → 0.46.39

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 (120) hide show
  1. package/README.md +960 -960
  2. package/dist/auth/auth.service.d.ts.map +1 -1
  3. package/dist/auth/auth.service.js +30 -4
  4. package/dist/auth/auth.service.js.map +1 -1
  5. package/dist/auth/consts/body.js +24 -24
  6. package/dist/emails/index.d.ts +3 -0
  7. package/dist/emails/index.d.ts.map +1 -0
  8. package/dist/emails/index.js +19 -0
  9. package/dist/emails/index.js.map +1 -0
  10. package/dist/emails/lib.d.ts +6 -0
  11. package/dist/emails/lib.d.ts.map +1 -0
  12. package/dist/emails/lib.js +43 -0
  13. package/dist/emails/lib.js.map +1 -0
  14. package/dist/emails/templates.d.ts +13 -0
  15. package/dist/emails/templates.d.ts.map +1 -0
  16. package/dist/emails/templates.js +63 -0
  17. package/dist/emails/templates.js.map +1 -0
  18. package/frontend/menu/components/create-panel.tsx.ejs +55 -55
  19. package/frontend/menu/components/update-panel.tsx.ejs +67 -67
  20. package/frontend/menu/locales/en/admin.menu.json +11 -11
  21. package/frontend/menu/locales/pt/admin.menu.json +11 -11
  22. package/frontend/menu/react-query/handlers.ts.ejs +28 -28
  23. package/frontend/menu/react-query/requests.ts.ejs +56 -56
  24. package/frontend/menu-locale/locales/en/admin.menu-locale.json +11 -11
  25. package/frontend/menu-locale/locales/pt/admin.menu-locale.json +11 -11
  26. package/frontend/menu-screen/locales/en/admin.menu-screen.json +11 -11
  27. package/frontend/menu-screen/locales/pt/admin.menu-screen.json +11 -11
  28. package/frontend/multifactor/components/create-panel.tsx.ejs +55 -55
  29. package/frontend/multifactor/components/update-panel.tsx.ejs +70 -70
  30. package/frontend/multifactor/locales/en/admin.multifactor.json +11 -11
  31. package/frontend/multifactor/locales/pt/admin.multifactor.json +11 -11
  32. package/frontend/multifactor/react-query/handlers.ts.ejs +28 -28
  33. package/frontend/multifactor/react-query/requests.ts.ejs +59 -59
  34. package/frontend/multifactor-locale/locales/en/admin.multifactor-locale.json +11 -11
  35. package/frontend/multifactor-locale/locales/pt/admin.multifactor-locale.json +11 -11
  36. package/frontend/screen/components/create-panel.tsx.ejs +55 -55
  37. package/frontend/screen/components/update-panel.tsx.ejs +67 -67
  38. package/frontend/screen/locales/en/admin.screen.json +11 -11
  39. package/frontend/screen/locales/pt/admin.screen.json +11 -11
  40. package/frontend/screen/react-query/handlers.ts.ejs +28 -28
  41. package/frontend/screen/react-query/requests.ts.ejs +56 -56
  42. package/frontend/screen-locale/locales/en/admin.screen-locale.json +11 -11
  43. package/frontend/screen-locale/locales/pt/admin.screen-locale.json +11 -11
  44. package/frontend/translation/components/create-panel.tsx.ejs +52 -52
  45. package/frontend/translation/components/update-panel.tsx.ejs +67 -67
  46. package/frontend/translation/locales/en/admin.translation.json +11 -11
  47. package/frontend/translation/locales/pt/admin.translation.json +11 -11
  48. package/frontend/translation/react-query/handlers.ts.ejs +28 -28
  49. package/frontend/translation/react-query/requests.ts.ejs +58 -58
  50. package/frontend/translation-namespace/components/create-panel.tsx.ejs +53 -53
  51. package/frontend/translation-namespace/components/update-panel.tsx.ejs +70 -70
  52. package/frontend/translation-namespace/locales/en/admin.translation-namespace.json +11 -11
  53. package/frontend/translation-namespace/locales/pt/admin.translation-namespace.json +11 -11
  54. package/frontend/translation-namespace/react-query/handlers.ts.ejs +28 -28
  55. package/frontend/translation-namespace/react-query/requests.ts.ejs +60 -60
  56. package/frontend/user/components/create-panel.tsx.ejs +52 -52
  57. package/frontend/user/components/update-panel.tsx.ejs +64 -64
  58. package/frontend/user/locales/en/admin.user.json +11 -11
  59. package/frontend/user/locales/pt/admin.user.json +11 -11
  60. package/frontend/user/react-query/handlers.ts.ejs +28 -28
  61. package/frontend/user/react-query/requests.ts.ejs +55 -55
  62. package/hedhog.yaml +783 -783
  63. package/package.json +45 -43
  64. package/src/admin.module.ts +39 -39
  65. package/src/auth/auth.controller.ts +88 -88
  66. package/src/auth/auth.module.ts +41 -41
  67. package/src/auth/auth.service.spec.ts +196 -196
  68. package/src/auth/auth.service.ts +349 -316
  69. package/src/auth/consts/body.ts +27 -27
  70. package/src/auth/dto/change.dto.ts +19 -19
  71. package/src/auth/dto/email.dto.ts +15 -15
  72. package/src/auth/dto/forget.dto.ts +6 -6
  73. package/src/auth/dto/login.dto.ts +21 -21
  74. package/src/auth/dto/otp.dto.ts +11 -11
  75. package/src/auth/dto/reset.dto.ts +14 -14
  76. package/src/auth/enums/multifactor-type.enum.ts +4 -4
  77. package/src/auth/guards/auth.guard.ts +54 -54
  78. package/src/auth/types/user.type.ts +8 -8
  79. package/src/dto/delete.dto.ts +8 -8
  80. package/src/dto/update-ids.dto.ts +9 -9
  81. package/src/emails/index.ts +2 -0
  82. package/src/emails/lib.ts +40 -0
  83. package/src/emails/templates.ts +60 -0
  84. package/src/index.ts +20 -20
  85. package/src/menu/dto/create.dto.ts +25 -25
  86. package/src/menu/dto/order.dto.ts +8 -8
  87. package/src/menu/dto/update.dto.ts +19 -19
  88. package/src/menu/menu.controller.ts +105 -105
  89. package/src/menu/menu.module.ts +18 -18
  90. package/src/menu/menu.service.spec.ts +247 -247
  91. package/src/menu/menu.service.ts +263 -263
  92. package/src/role/dto/create.dto.ts +7 -7
  93. package/src/role/dto/update.dto.ts +4 -4
  94. package/src/role/guards/role.guard.ts +121 -121
  95. package/src/role/role.controller.ts +126 -126
  96. package/src/role/role.module.ts +28 -28
  97. package/src/role/role.service.spec.ts +417 -417
  98. package/src/role/role.service.ts +289 -289
  99. package/src/route/dto/create.dto.ts +13 -13
  100. package/src/route/dto/update.dto.ts +15 -15
  101. package/src/route/route.controller.ts +91 -91
  102. package/src/route/route.module.ts +18 -18
  103. package/src/route/route.service.spec.ts +300 -300
  104. package/src/route/route.service.ts +164 -164
  105. package/src/screen/dto/create.dto.ts +11 -11
  106. package/src/screen/dto/update.dto.ts +19 -19
  107. package/src/screen/screen.controller.ts +93 -93
  108. package/src/screen/screen.module.ts +18 -18
  109. package/src/screen/screen.service.spec.ts +298 -298
  110. package/src/screen/screen.service.ts +179 -179
  111. package/src/types/http-method.ts +8 -8
  112. package/src/user/constants/user.constants.ts +1 -1
  113. package/src/user/dto/create.dto.ts +24 -24
  114. package/src/user/dto/update.dto.ts +41 -41
  115. package/src/user/user.controller.ts +75 -75
  116. package/src/user/user.module.ts +18 -18
  117. package/src/user/user.service.spec.ts +294 -294
  118. package/src/user/user.service.ts +129 -129
  119. package/tsconfig.lib.json +9 -9
  120. package/tsconfig.production.json +20 -20
package/README.md CHANGED
@@ -1,960 +1,960 @@
1
- # <p align="center">hedhog/admin</p>
2
-
3
- <p align="center">
4
- <img src="https://avatars.githubusercontent.com/u/177489127?s=200&v=4" alt="Hedhog Avatar" />
5
- </p>
6
-
7
- ## Table of Contents
8
-
9
- - [Overview](#overview)
10
- - [Hedhog Auth](#hedhog-auth)
11
- - [Hedhog Locale](#hedhog-locale)
12
- - [Hedhog Menu](#hedhog-menu)
13
- - [Hedhog Role](#hedhog-role)
14
- - [Hedhog Route](#hedhog-route)
15
- - [Hedhog Screen](#hedhog-screen)
16
- - [Hedhog Setting](#hedhog-setting)
17
- - [Hedhog User](#hedhog-user)
18
-
19
- # Overview
20
-
21
- The **Hedhog Admin** module is a collection of core modules essential for managing and administering applications within the HedHog framework. It brings together various modules that provide key functionalities such as authentication, menu configuration, permissions, screen management and user management.
22
-
23
- Whether you need to secure access to resources, manage user role, or handle file uploads, the `@hedhog/admin` module provides everything required to manage a modern web application’s backend with minimal setup.
24
-
25
- ### Included Modules<
26
-
27
- - **@hedhog/auth**: Provides authentication and authorization mechanisms, ensuring secure access to application resources.
28
- - **@hedhog/locale**: Provides solution for managing locale and translation across applications.
29
- - **@hedhog/menu**: Allows for the creation and management of dynamic menu within the application interface.
30
- - **@hedhog/role**: Facilitates the management of role, controlling access to specific features or areas.
31
- - **@hedhog/route**: Provides a comprehensive system for managing route within your application.
32
- - **@hedhog/setting**: Provides a solution for managing application setting.
33
- - **@hedhog/screen**: Provides a structure for managing different screens and UI components.
34
- - **@hedhog/user**: Manages user accounts, including creation, updates, and deletion, along with password encryption and secure access.
35
-
36
- ### Installation
37
-
38
- To install the `@hedhog/admin` module, use npm:
39
-
40
- ```bash
41
- npm install @hedhog/admin
42
- ```
43
-
44
- ### Usage
45
-
46
- The `@hedhog/admin` module acts as a base for administrative tasks in HedHog applications. Once installed, you can integrate the included modules into your project to quickly set up and manage essential features for your admin interface.
47
-
48
- ```typescript
49
- import { AdminModule } from '@hedhog/admin';
50
-
51
- @Module({
52
- imports: [AdminModule],
53
- })
54
- export class AppModule {}
55
- ```
56
-
57
- By importing the AdminModule, you gain access to all the functionality provided by the individual modules, making it easier to manage authentication, permissions, user, and more.
58
-
59
- ---
60
-
61
- # Hedhog Auth
62
-
63
- **HedHog Auth** is a library designed to handle authentication tasks within the HedHog framework. It provides functionalities for user login, token management, multi-factor authentication (MFA), and password reset, ensuring secure and reliable user authentication processes.
64
-
65
- ### Features
66
-
67
- - **Token Verification**: Verify authentication tokens for user.
68
- - **Login**: Authenticate user with email and password, and handle multi-factor authentication if required.
69
- - **OTP Management**: Manage one-time passwords (OTP) for multi-factor authentication.
70
- - **Password Reset**: Facilitate password reset requests through email.
71
-
72
- #### Controller
73
-
74
- The `AuthController` defines the following endpoints:
75
-
76
- - `GET /auth/verify`: Verify the authentication status of the user.
77
- - `POST /auth/login`: Authenticate a user using email and password.
78
- - `POST /auth/otp`: Verify an OTP code for multi-factor authentication.
79
- - `POST /auth/forget`: Request a password reset link via email.
80
-
81
- #### AuthService
82
-
83
- The `AuthService` provides methods for:
84
-
85
- - `verifyToken(token: string)`: Verify the provided JWT token.
86
- - `generateRandomString(length: number)`: Generate a random string of specified length.
87
- - `generateRandomNumber()`: Generate a random 6-digit number.
88
- - `loginWithEmailAndPassword(email: string, password: string)`: Authenticate user with email and password and handle multi-factor authentication if required.
89
- - `getToken(user)`: Generate a JWT token for the authenticated user.
90
- - `forget({ email }: ForgetDTO)`: Initiate a password reset process for the specified email.
91
- - `otp({ token, code }: OtpDTO)`: Verify the OTP code provided by the user.
92
-
93
- ### Folder Structure
94
-
95
- ```plaintext
96
- ├── auth.controller.ts # Defines route for authentication
97
- ├── auth.service.ts # Contains authentication logic
98
- ├── auth.service.spec.ts # Testing file for auth service
99
- ├── auth.module.ts # Authentication module
100
- ├── dto/
101
- │ ├── forget.dto.ts # Data Transfer Object for password reset
102
- │ ├── login.dto.ts # Data Transfer Object for login
103
- │ └── otp.dto.ts # Data Transfer Object for OTP verification
104
- ├── decorators/
105
- │ ├── public.decorator.ts # Custom decorator to mark public route
106
- │ └── user.decorator.ts # Custom decorator to get user from request
107
- ├── types/
108
- │ └── user.type.ts # Type definitions for user-related data
109
- ├── enums/
110
- │ └── multifactor-type.enum.ts # Enumeration for multi-factor authentication types
111
- ├── guards/
112
- │ └── auth.guard.ts # Guard for protecting route
113
- ```
114
-
115
- ---
116
-
117
- # Hedhog Locale
118
-
119
- **Hedhog Locale** module provides a powerful solution for managing locale and translation across applications. It includes functionalities to retrieve, create, update, and delete locale data, with support for pagination and localization. The module integrates seamlessly within the HedHog ecosystem, using @hedhog/pagination for handling paginated responses and @hedhog/prisma for database interactions.
120
-
121
- ### Controller Endpoints
122
-
123
- #### `GET /locale/system/enables`
124
-
125
- - **Description**: Retrieve a paginated list of enabled locale.
126
- - **Authentication**: Not required (public endpoint).
127
- - **Parameters**:
128
- - `locale (string)`: Locale code for filtering.
129
- - Pagination parameters (optional).
130
-
131
- #### `GET /locale/:localeCode/:namespace`
132
-
133
- - **Description**: Retrieve translation for a specific locale and namespace.
134
- - **Authentication**: Not required (public endpoint).
135
- - **Parameters**:
136
- - `localeCode (string)`: The locale code to fetch translation for.
137
- - `namespace (string)`: The namespace to fetch translation from.
138
-
139
- #### `GET /locale`
140
-
141
- - **Description**: Retrieve a paginated list of locale.
142
- - **Authentication**: Required.
143
- - **Pagination**: Supports pagination through query parameters.
144
-
145
- #### `GET /locale/:id`
146
-
147
- - **Description**: Retrieve a specific locale by its ID.
148
- - **Authentication**: Required.
149
- - **Parameters**:
150
- - `id (number)`: The ID of the locale to retrieve.
151
-
152
- #### `POST /locale`
153
-
154
- - **Description**: Create a new locale entry.
155
- - **Authentication**: Required.
156
- - **Body**:
157
- - `code (string)`: The code of the locale.
158
- - `region (string)`: The region of the locale.
159
-
160
- #### `PATCH /locale/:id`
161
-
162
- - **Description**: Update an existing locale entry.
163
- - **Authentication**: Required.
164
- - **Parameters**:
165
- - `id (number)`: The ID of the locale to update.
166
- - **Body**:
167
- - `code (string, optional)`: Updated code of the locale.
168
- - `region (string, optional)`: Updated region of the locale.
169
-
170
- #### `DELETE /locale`
171
-
172
- - **Description**: Delete one or more locale.
173
- - **Authentication**: Required.
174
- - **Body**:
175
- - `ids (number[])`: Array of locale IDs to delete.
176
-
177
- ### Service Methods
178
-
179
- #### `getEnables(locale: string, paginationParams: PaginationDTO)`
180
-
181
- - **Description**: Retrieves a paginated list of enabled locale based on locale code and pagination parameters.
182
- - **Parameters**:
183
- - `locale (string)`: Locale code for filtering.
184
- - `paginationParams (PaginationDTO)`: Includes pagination criteria.
185
-
186
- #### `getTranslations(localeCode: string, namespace: string)`
187
-
188
- - **Description**: Retrieves translation for a given locale code and namespace.
189
- - **Parameters**:
190
- - `localeCode (string)`: The locale code to fetch translation for.
191
- - `namespace (string)`: The namespace to fetch translation from.
192
-
193
- #### `get(paginationParams: PaginationDTO)`
194
-
195
- - **Description**: Retrieves a paginated list of all locale.
196
- - **Parameters**:
197
- - `paginationParams (PaginationDTO)`: Includes pagination criteria.
198
-
199
- #### `getById(localeId: number)`
200
-
201
- - **Description**: Retrieves a specific locale by its ID.
202
- - **Parameters**:
203
- - `localeId (number)`: ID of the locale to retrieve.
204
-
205
- #### `create(data: CreateDTO)`
206
-
207
- - **Description**: Creates a new locale entry.
208
- - **Parameters**:
209
- - `data (CreateDTO)`: Includes code and region of the new locale.
210
-
211
- #### `update(id: number, data: UpdateDTO)`
212
-
213
- - **Description**: Updates an existing locale entry.
214
- - **Parameters**:
215
- - `id (number)`: ID of the locale to update.
216
- - `data (UpdateDTO)`: Includes updated code and region.
217
-
218
- #### `delete(data: DeleteDTO)`
219
-
220
- - **Description**: Deletes one or more locale entries.
221
- - **Parameters**:
222
- - `data (DeleteDTO)`: Includes array of IDs to delete.
223
-
224
- ### Folder Structure
225
-
226
- ```plaintext
227
- |── dto/ # Data Transfer Objects
228
- │ ├── create.dto.ts # DTO for creating locale
229
- │ ├── delete.dto.ts # DTO for deleting locale
230
- │ └── update.dto.ts # DTO for updating locale
231
- |── locale.controller.ts # Controller for locale
232
- |── locale.decorator.ts # Decorator for injecting locale into requests
233
- |── locale.middleware.ts # Middleware to handle locale-specific processing
234
- |── locale.module.ts # Module definition for locale
235
- |── locale.service.ts # Service class for locale logic
236
- ├── locale.service.spec.ts # Testing file for locale service
237
- |── index.ts # Main export file for the module
238
- ```
239
-
240
- ---
241
-
242
- # Hedhog Menu
243
-
244
- **HedHog Menu** is a library for managing menu within the HedHog framework. It provides a set of RESTful endpoints for CRUD operations on menu items, as well as functionalities to handle pagination and ordering of menu.
245
-
246
- ### Features
247
-
248
- - **CRUD Operations**: Create, Read, Update, and Delete menu items.
249
- - **Pagination**: Paginate menu items for efficient data retrieval.
250
- - **Ordering**: Update the order of menu items.
251
-
252
- ### MenuController
253
-
254
- The `MenuController` exposes the following endpoints:
255
-
256
- - **GET /menu**: Retrieve a list of menu with pagination.
257
- - **GET /menu/:menuId**: Retrieve a specific menu by ID.
258
- - **POST /menu**: Create a new menu item.
259
- - **PATCH /menu/:menuId**: Update an existing menu item by ID.
260
- - **DELETE /menu**: Delete menu items based on provided IDs.
261
- - **PATCH /menu/order**: Update the order of menu items.
262
-
263
- ### MenuService
264
-
265
- The `MenuService` class contains the business logic for handling menu operations, including querying the database and processing data.
266
-
267
- - **getMenu(paginationParams: PaginationDTO)**: Retrieves a paginated list of menu items.
268
- - **get(menuId: number)**: Retrieves a menu item by ID.
269
- - **create(data: CreateDTO)**: Creates a new menu item.
270
- - **update({ id, data }: { id: number; data: UpdateDTO })**: Updates an existing menu item by ID.
271
- - **delete(data: DeleteDTO)**: Deletes menu items based on provided IDs.
272
- - **updateOrder(data: OrderDTO)**: Updates the order of menu items.
273
-
274
- ### Folder Structure
275
-
276
- ```plaintext
277
- ├── menu.controller.ts # Handles HTTP requests related to menu
278
- ├── menu.service.ts # Contains business logic for menu operations
279
- ├── menu.service.spec.ts # Testing file for menu service
280
- ├── menu.module.ts # Module definition for menu functionalities
281
- ├── dto/
282
- │ ├── create.dto.ts # Data Transfer Object for creating a menu
283
- │ ├── update.dto.ts # Data Transfer Object for updating a menu
284
- └── order.dto.ts # Data Transfer Object for updating menu order
285
- ```
286
-
287
- ---
288
-
289
- # Hedhog Role
290
-
291
- **HedHog Role** module is designed to handle role management within the HedHog framework. It allows for creating, updating, and deleting role and managing their relationships with user, menu, route, and screens.
292
-
293
- ### Features
294
-
295
- - **Role Management**: Create, update, and delete role.
296
- - **User Associations**: Assign and manage user associated with role.
297
- - **Menu, Route, and Screen Associations**: Manage the association between role and menu, route, or screens.
298
- - **Pagination**: Handle paginated responses for all resources.
299
-
300
- ### Controller Endpoints
301
-
302
- #### `GET /role`
303
-
304
- - **Description**: Retrieve a paginated list of all role.
305
- - **Authentication**: Required (uses `AuthGuard`).
306
- - **Parameters**:
307
- - `paginationParams` (optional): Standard pagination parameters.
308
-
309
- #### `GET /role/:roleId`
310
-
311
- - **Description**: Retrieve details of a specific role.
312
- - **Authentication**: Required (uses `AuthGuard`).
313
- - **Parameters**:
314
- - `roleId (number)`: The ID of the role to retrieve.
315
-
316
- #### `POST /role`
317
-
318
- - **Description**: Create a new role.
319
- - **Authentication**: Required (uses `AuthGuard`).
320
- - **Parameters**:
321
- - `data` (CreateDTO): The data for the new role (name, description, etc).
322
-
323
- #### `PATCH /role/:roleId`
324
-
325
- - **Description**: Update an existing role.
326
- - **Authentication**: Required (uses `AuthGuard`).
327
- - **Parameters**:
328
- - `roleId (number)`: The ID of the role to update.
329
- - `data` (UpdateDTO): The data to update for the role.
330
-
331
- #### `DELETE /role`
332
-
333
- - **Description**: Delete one or more role.
334
- - **Authentication**: Required (uses `AuthGuard`).
335
- - **Parameters**:
336
- - `data` (DeleteDTO): List of role IDs to delete.
337
-
338
- #### `GET /role/:roleId/user`
339
-
340
- - **Description**: Get a list of user associated with a specific role.
341
- - **Authentication**: Required (uses `AuthGuard`).
342
- - **Parameters**:
343
- - `roleId (number)`: The ID of the role to retrieve user for.
344
- - `paginationParams` (optional): Standard pagination parameters.
345
-
346
- #### `GET /role/:roleId/menu`
347
-
348
- - **Description**: Get a list of menu associated with a specific role.
349
- - **Authentication**: Required (uses `AuthGuard`).
350
- - **Parameters**:
351
- - `roleId (number)`: The ID of the role to retrieve menu for.
352
- - `paginationParams` (optional): Standard pagination parameters.
353
-
354
- #### `GET /role/:roleId/route`
355
-
356
- - **Description**: Get a list of route associated with a specific role.
357
- - **Authentication**: Required (uses `AuthGuard`).
358
- - **Parameters**:
359
- - `roleId (number)`: The ID of the role to retrieve route for.
360
- - `paginationParams` (optional): Standard pagination parameters.
361
-
362
- #### `GET /role/:roleId/screens`
363
-
364
- - **Description**: Get a list of screens associated with a specific role.
365
- - **Authentication**: Required (uses `AuthGuard`).
366
- - **Parameters**:
367
- - `roleId (number)`: The ID of the role to retrieve screens for.
368
- - `paginationParams` (optional): Standard pagination parameters.
369
-
370
- #### `PATCH /role/:roleId/user`
371
-
372
- - **Description**: Update the user associated with a specific role.
373
- - **Authentication**: Required (uses `AuthGuard`).
374
- - **Parameters**:
375
- - `roleId (number)`: The ID of the role. -`data` (UpdateIdsDTO): List of user IDs to associate with the role.
376
-
377
- #### `PATCH /role/:roleId/menu`
378
-
379
- - **Description**: Update the menu associated with a specific role.
380
- - **Authentication**: Required (uses `AuthGuard`).
381
- - **Parameters**:
382
- - `roleId (number)`: The ID of the role.
383
- - `data` (UpdateIdsDTO): List of menu IDs to associate with the role.
384
-
385
- #### `PATCH /role/:roleId/route`
386
-
387
- - **Description**: Update the route associated with a specific role.
388
- - **Authentication**: Required (uses `AuthGuard`).
389
- - **Parameters**:
390
- - `roleId (number)`: The ID of the role.
391
- - `data` (UpdateIdsDTO): List of route IDs to associate with the role.
392
-
393
- #### `PATCH /role/:roleId/screens`
394
-
395
- - **Description**: Update the screens associated with a specific role.
396
- - **Authentication**: Required (uses `AuthGuard`).
397
- - **Parameters**:
398
- - `roleId (number)`: The ID of the role.
399
- - `data` (UpdateIdsDTO): List of screen IDs to associate with the role.
400
-
401
- ### Service Methods
402
-
403
- #### `updateUsers(roleId: number, { ids }: UpdateIdsDTO)`
404
-
405
- - **Description**: Updates the user associated with a specific role by deleting existing associations and creating new ones.
406
- - **Parameters**:
407
- - `roleId (number)`: The ID of the role to update.
408
- - `data`: An object containing an array of user IDs to associate with the role.
409
-
410
- #### `updateScreens(roleId: number, data: UpdateIdsDTO)`
411
-
412
- - **Description**: Updates the screens associated with a specific role by deleting existing associations and creating new ones.
413
- - **Parameters**:
414
- - `roleId (number)`: The ID of the role to update.
415
- - `data`: An object containing an array of screen IDs to associate with the role.
416
-
417
- #### `updateRoutes(roleId: number, data: UpdateIdsDTO)`
418
-
419
- - **Description**: Updates the route associated with a specific role by deleting existing associations and creating new ones.
420
- - **Parameters**:
421
- - `roleId (number)`: The ID of the role to update.
422
- - `data`: An object containing an array of route IDs to associate with the role.
423
-
424
- #### `updateMenus(roleId: number, data: UpdateIdsDTO)`
425
-
426
- - **Description**: Updates the menu associated with a specific role by deleting existing associations and creating new ones.
427
- - **Parameters**:
428
- - `roleId (number)`: The ID of the role to update.
429
- - `data`: An object containing an array of menu IDs to associate with the role.
430
-
431
- #### `listUsers(roleId: number, paginationParams: PaginationDTO)`
432
-
433
- - **Description**: Retrieves a paginated list of user associated with a specific role.
434
- - **Parameters**:
435
- - `roleId (number)`: The ID of the role to retrieve associated user.
436
- - `paginationParams`: Includes pagination criteria.
437
-
438
- #### `listMenus(roleId: number, paginationParams: PaginationDTO)`
439
-
440
- - **Description**: Retrieves a paginated list of menu associated with a specific role.
441
- - **Parameters**:
442
- - `roleId (number)`: The ID of the role to retrieve associated menu.
443
- - `paginationParams`: Includes pagination criteria.
444
-
445
- #### `listRoutes(roleId: number, paginationParams: PaginationDTO)`
446
-
447
- - **Description**: Retrieves a paginated list of route associated with a specific role.
448
- - **Parameters**:
449
- - `roleId (number)`: The ID of the role to retrieve associated route.
450
- - `paginationParams`: Includes pagination criteria.
451
-
452
- #### `listScreens(roleId: number, paginationParams: PaginationDTO)`
453
-
454
- - **Description**: Retrieves a paginated list of screens associated with a specific role.
455
- - **Parameters**:
456
- - `roleId (number)`: The ID of the role to retrieve associated screens.
457
- - `paginationParams`: Includes pagination criteria.
458
-
459
- #### `getRoles(paginationParams: PaginationDTO)`
460
-
461
- - **Description**: Retrieves a paginated list of all role, with optional search functionality based on name and description.
462
- - **Parameters**:
463
- - `paginationParams`: Includes pagination and search criteria.
464
-
465
- #### `get(roleId: number)`
466
-
467
- - **Description**: Retrieves a specific role by its ID.
468
- - **Parameters**:
469
- - `roleId (number)`: The ID of the role to retrieve.
470
-
471
- #### `create(data: CreateDTO)`
472
-
473
- - **Description**: Creates a new role with the specified name and description.
474
- - **Parameters**:
475
- - `data`: An object containing the following properties:
476
- - `name (string)`: The name of the new role.
477
- - `description (string)`: A description of the new role.
478
-
479
- #### `update({ id, data }: { id: number; data: UpdateDTO })`
480
-
481
- - **Description**: Updates an existing role identified by its ID.
482
- - **Parameters**:
483
- - `id (number)`: The ID of the role to update.
484
- - `data`: An object containing the updated information for the role, defined in UpdateDTO.
485
-
486
- #### `delete({ ids }: DeleteDTO)`
487
-
488
- - **Description**: Deletes one or more role identified by their IDs.
489
- - **Parameters**:
490
- - `ids (array of number)`: An array containing the IDs of the role to delete.
491
-
492
- ### Folder Structure
493
-
494
- ```plaintext
495
- ├── decorators/
496
- │ ├── role.decorator.ts # Custom decorator for role
497
- ├── dto/ # Data Transfer Objects
498
- │ ├── create.dto.ts # DTO for creating a role
499
- │ ├── update.dto.ts # DTO for updating a role
500
- ├── guards/
501
- │ └── role.guard.ts # Guard for role
502
- ├── role.controller.ts # Handles HTTP requests related to role
503
- ├── role.module.ts # Module definition for the role
504
- └── role.service.ts # Service class for role-related logic
505
- └── role.service.spec.ts # Testing file for role service
506
- ```
507
-
508
- ---
509
-
510
- # Hedhog Route
511
-
512
- **Hedhog Route** module provides a comprehensive system for managing route within your application. It allows administrators to define, modify, and control access to different route within the application. The module also integrates with other Hedhog modules to ensure that permissions and role are respected when accessing route.
513
-
514
- ### Features
515
-
516
- - **CRUD Operations**: Create, Read, Update, and Delete route.
517
- - **Route Management**: Manage application route, including their accessibility and assignment to user role.
518
- - **Permissions Integration**: Integrates with Hedhog Permission to control access to specific route based on user role.
519
-
520
- ### Controller Endpoints
521
-
522
- #### `GET /route`
523
-
524
- - **Description**: Retrieves a paginated list of all route.
525
- - **Authentication**: Required (uses `AuthGuard`).
526
- - **Parameters**:
527
- - `paginationParams`: Includes pagination criteria.
528
-
529
- #### `GET /route/:routeId`
530
-
531
- - **Description**: Retrieves a specific route by its ID.
532
- - **Authentication**: Required (uses `AuthGuard`).
533
- - **Parameters**:
534
- - `routeId (number)`: The ID of the route to retrieve.
535
-
536
- #### `POST /route`
537
-
538
- - **Description**: Creates a new route with the specified URL and method.
539
- - **Authentication**: Required (uses `AuthGuard`).
540
- - **Parameters**:
541
- - `data`: An object containing the url and method for the new route.
542
-
543
- #### `PATCH /route/:routeId`
544
-
545
- - **Description**: Updates an existing route identified by its ID.
546
- - **Authentication**: Required (uses `AuthGuard`).
547
- - **Parameters**:
548
- - `routeId (number)`: The ID of the route to update.
549
- - `data`: An object containing the updated information for the route.
550
-
551
- #### `DELETE /route`
552
-
553
- - **Description**: Deletes one or more route.
554
- - **Authentication**: Required (uses `AuthGuard`).
555
- - **Parameters**:
556
- - `data`: An object containing an array of route IDs to delete.
557
-
558
- #### `GET /route/:routeId/role`
559
-
560
- - **Description**: Retrieves a paginated list of role associated with a specific route.
561
- - **Authentication**: Required (uses `AuthGuard`).
562
- - **Parameters**:
563
- - `routeId (number)`: The ID of the route to retrieve associated role.
564
- - `paginationParams`: Includes pagination criteria.
565
-
566
- #### `PATCH /route/:routeId/role`
567
-
568
- - **Description**: Updates the role associated with a specific route.
569
- - **Authentication**: Required (uses `AuthGuard`).
570
- - **Parameters**:
571
- - `routeId (number)`: The ID of the route.
572
- - `data`: An object containing an array of role IDs to associate with the route.
573
-
574
- #### `GET /route/:routeId/screens`
575
-
576
- - **Description**: Retrieves a paginated list of screens associated with a specific route.
577
- - **Authentication**: Required (uses `AuthGuard`).
578
- - **Parameters**:
579
- - `routeId (number)`: The ID of the route to retrieve associated screens.
580
- - `paginationParams`: Includes pagination criteria.
581
-
582
- #### `PATCH /route/:routeId/screens`
583
-
584
- - **Description:** Updates the screens associated with a specific route.
585
- - **Authentication**: Required (uses AuthGuard).
586
- - **Parameters**:
587
- - `routeId (number)`: The ID of the route.
588
- - `data`: An object containing an array of screen IDs to associate with the route.
589
-
590
- ### Service Methods
591
-
592
- #### `getRoutes(paginationParams: PaginationDTO)`
593
-
594
- - **Description**: Retrieves a paginated list of route with optional search functionality based on URL and method.
595
- - **Parameters**:
596
- - `paginationParams`: Includes pagination and search criteria.
597
-
598
- #### `getRouteById(routeId: number)`
599
-
600
- - **Description**: Retrieves a specific route by its ID.
601
- - **Parameters**:
602
- - `routeId`: The ID of the route to retrieve.
603
-
604
- #### `create(data: CreateDTO)`
605
-
606
- - **Description**: Creates a new route with the specified URL and method.
607
- - **Parameters**:
608
- - `data`: An object containing the URL and method for the new route.
609
-
610
- #### `update({ id, data }: { id: number; data: UpdateDTO })`
611
-
612
- - **Description**: Updates an existing route identified by its ID.
613
- - **Parameters**:
614
- - `id`: The ID of the route to update.
615
- - `data`: An object containing the updated information for the route.
616
-
617
- #### `delete({ ids }: DeleteDTO)`
618
-
619
- - **Description**: Deletes one or more route identified by their IDs.
620
- - **Parameters**:
621
- - `ids`: An object containing an array of route IDs to delete.
622
-
623
- #### `listRoles(routeId: number, paginationParams: PaginationDTO)`
624
-
625
- - **Description**: Retrieves a paginated list of role associated with a specific route.
626
- - **Parameters**:
627
- - `routeId`: The ID of the route to retrieve associated role.
628
- - `paginationParams`: Includes pagination parameters.
629
-
630
- #### `updateRoles(routeId: number, data: UpdateIdsDTO)`
631
-
632
- - **Description**: Updates the role associated with a specific route.
633
- - **Parameters**:
634
- - `routeId`: The ID of the route.
635
- - `data`: An object containing an array of role IDs to associate with the route.
636
-
637
- #### `listScreens(routeId: number, paginationParams: PaginationDTO)`
638
-
639
- - **Description**: Retrieves a paginated list of screens associated with a specific route.
640
- - **Parameters**:
641
- - `routeId`: The ID of the route to retrieve associated screens.
642
- - `paginationParams`: Includes pagination parameters.
643
-
644
- #### `updateScreens(routeId: number, data: UpdateIdsDTO)`
645
-
646
- - **Description**: Updates the screens associated with a specific route.
647
- - **Parameters**:
648
- - `routeId`: The ID of the route.
649
- - `data`: An object containing an array of screen IDs to associate with the route.
650
-
651
- ### Folder Structure
652
-
653
- ```plaintext
654
- ├── dto/ # Data Transfer Objects
655
- │ ├── create.dto.ts # DTO for creating a route
656
- │ ├── update.dto.ts # DTO for updating a route
657
- ├── guards/
658
- │ └── route.guard.ts # Guard for route
659
- ├── route.controller.ts # Handles HTTP requests related to route
660
- ├── route.module.ts # Module definition for the route
661
- ├── route.service.ts # Service class for route-related logic
662
- └── route.service.spec.ts # Testing file for route service
663
- ```
664
-
665
- ---
666
-
667
- # Hedhog Setting
668
-
669
- **Hedhog Setting** module provides a comprehensive solution for managing application setting. It includes functionalities to create, read, update, and delete setting, along with support for pagination and search capabilities. This module integrates with the HedHog ecosystem, utilizing @hedhog/pagination for managing paginated results and @hedhog/prisma for database interactions.
670
-
671
- ### Controller Endpoints
672
-
673
- #### `GET /setting`
674
-
675
- - **Description**: Retrieve a paginated list of setting.
676
- - **Authentication**: Required (uses `AuthGuard`).
677
- - **Pagination**: Supports pagination through query parameters.
678
-
679
- #### `GET /setting/:settingId`
680
-
681
- - **Description**: Retrieve a specific setting by its ID.
682
- - **Authentication**: Required (uses AuthGuard).
683
- - **Parameters**:
684
- - **settingId** (number): The ID of the setting to retrieve.
685
-
686
- #### `POST /setting`
687
-
688
- - **Description**: Create a new setting.
689
- - **Authentication**: Required (uses AuthGuard).
690
- - **Body**:
691
- - **name** (string): Name of the setting.
692
-
693
- #### `PATCH /setting/:settingId`
694
-
695
- - **Description**: Update an existing setting.
696
- - **Authentication**: Required (uses AuthGuard).
697
- - **Parameters**:
698
- - **settingId** (number): The ID of the setting to update.
699
- - **Body**:
700
- - **name** (string, optional): Updated name of the setting.
701
-
702
- #### `DELETE /setting`
703
-
704
- - **Description**: Delete one or more setting.
705
- - **Authentication**: Required (uses AuthGuard).
706
- - **Body**:
707
- - **ids** (number[]): Array of setting IDs to delete.
708
-
709
- ### Service Methods
710
-
711
- #### `getSettings(paginationParams: PaginationDTO)`
712
-
713
- - **Description**: Retrieves a paginated list of setting with optional search functionality.
714
- - **Parameters**:
715
- - **paginationParams**: Includes pagination and search criteria.
716
-
717
- #### `get(settingId: number)`
718
-
719
- - **Description**: Retrieves a specific setting by its ID.
720
- - **Parameters**:
721
- - **settingId**: ID of the setting to retrieve.
722
-
723
- #### `create(data: CreateDTO)`
724
-
725
- - **Description**: Creates a new setting.
726
- - **Parameters**:
727
- - **data**: Includes name of the setting.
728
-
729
- #### `update(id: number, data: UpdateDTO)`
730
-
731
- - **Description**: Updates an existing setting.
732
- - **Parameters**:
733
- - **id**: ID of the setting to update.
734
- - **data**: Includes updated name of the setting.
735
-
736
- #### `delete(data: DeleteDTO)`
737
-
738
- - **Description**: Deletes one or more setting.
739
- - **Parameters**:
740
- - **data**: Includes array of ids to delete.
741
-
742
- ## Folder Structure
743
-
744
- ```plaintext
745
- |── dto/ # Data Transfer Objects
746
- │ |── create.dto.ts # DTO for creating setting
747
- │ |── delete.dto.ts # DTO for deleting setting
748
- │ |── update.dto.ts # DTO for updating setting
749
- |── setting.controller.ts # Controller for setting
750
- |── setting.module.ts # Module definition for setting
751
- |── setting.service.ts # Service class for setting logic
752
- |── setting.service.spec.ts # Testing file for setting service
753
- ```
754
-
755
- ---
756
-
757
- # Hedhog Screen
758
-
759
- **Hedhog Screen** module is part of the HedHog framework and provides functionalities for managing screens in your application. It offers a set of RESTful API endpoints and service methods to handle CRUD operations and pagination for screens.
760
-
761
- ### Features
762
-
763
- - Create, Read, Update, and Delete (**CRUD**) operations for screens.
764
- - **Pagination** for listing screens.
765
- - **Search** functionality to filter screens based on various attributes.
766
-
767
- ### Controller Endpoints
768
-
769
- #### `GET /screens`
770
-
771
- - **Description**: Retrieve a paginated list of screens.
772
- - **Authentication**: Required (uses `AuthGuard`).
773
- - **Pagination**: Supports pagination through query parameters.
774
-
775
- #### `GET /screens/:screenId`
776
-
777
- - **Description**: Retrieve a specific screen by its ID.
778
- - **Authentication**: Required (uses `AuthGuard`).
779
- - **Parameters**:
780
- - `screenId` (number): The ID of the screen to retrieve.
781
-
782
- #### `POST /screens`
783
-
784
- - **Description**: Create a new screen.
785
- - **Authentication**: Required (uses `AuthGuard`).
786
- - **Body**:
787
- - `name` (string): Name of the screen.
788
- - `slug` (string): Unique identifier for the screen.
789
- - `description` (string): Description of the screen.
790
- - `icon` (string): Icon associated with the screen.
791
-
792
- #### `PATCH /screens/:screenId`
793
-
794
- - **Description**: Update an existing screen.
795
- - **Authentication**: Required (uses `AuthGuard`).
796
- - **Parameters**:
797
- - `screenId` (number): The ID of the screen to update.
798
- - **Body**:
799
- - `name` (string, optional): Updated name of the screen.
800
- - `slug` (string, optional): Updated slug of the screen.
801
- - `description` (string, optional): Updated description of the screen.
802
- - `icon` (string, optional): Updated icon of the screen.
803
-
804
- #### `DELETE /screens`
805
-
806
- - **Description**: Delete one or more screens.
807
- - **Authentication**: Required (uses `AuthGuard`).
808
- - **Body**:
809
- - `ids` (number[]): Array of screen IDs to delete.
810
-
811
- ### Service Methods
812
-
813
- #### `getScreens(paginationParams: PaginationDTO)`
814
-
815
- - **Description**: Retrieves a paginated list of screens with optional search functionality.
816
- - **Parameters**:
817
- - `paginationParams`: Includes pagination and search criteria.
818
-
819
- #### `get(screenId: number)`
820
-
821
- - **Description**: Retrieves a specific screen by its ID.
822
- - **Parameters**:
823
- - `screenId`: ID of the screen to retrieve.
824
-
825
- #### `create(data: CreateDTO)`
826
-
827
- - **Description**: Creates a new screen.
828
- - **Parameters**:
829
- - `data`: Includes `name`, `slug`, `description`, and `icon`.
830
-
831
- #### `update(id: number, data: UpdateDTO)`
832
-
833
- - **Description**: Updates an existing screen.
834
- - **Parameters**:
835
- - `id`: ID of the screen to update.
836
- - `data`: Includes updated `name`, `slug`, `description`, and `icon`.
837
-
838
- #### `delete(data: DeleteDTO)`
839
-
840
- - **Description**: Deletes one or more screens.
841
- - **Parameters**:
842
- - `data`: Includes array of `ids` to delete.
843
-
844
- ### Folder Structure
845
-
846
- ```plaintext
847
- ├── dto/ # Data Transfer Objects
848
- │ ├── create.dto.ts # DTO for creating a screen
849
- │ ├── update.dto.ts # DTO for updating a screen
850
- ├── screen.controller.ts # Handles HTTP requests related to screens
851
- ├── screen.module.ts # Module definition for the screen
852
- └── screen.service.ts # Service class for screen-related logic
853
- └── screen.service.spec.ts # Testing file for screen service
854
- ```
855
-
856
- ---
857
-
858
- # Hedhog User
859
-
860
- The **Hedhog User** module in HedHog provides functionality to manage user data within an application. This module leverages the HedHog framework components, including pagination and [**Prisma**](https://www.prisma.io/) integration, to offer a robust user management system.
861
-
862
- ### Integrations
863
-
864
- - **Pagination**: Utilizes `@hedhog/pagination` for managing paginated results of user queries.
865
- - **Database Interaction**: Uses `@hedhog/prisma` to interface with the database for user data management.
866
- - **Authentication**: Secured with Auth Module from `@hedhog/admin` to ensure that only authorized user can access or modify user data.
867
-
868
- ### Controller Endpoints
869
-
870
- #### `GET /user`
871
-
872
- - **Description**: Retrieve a paginated list of user.
873
- - **Authentication**: Required (uses `AuthGuard`).
874
- - **Pagination**: Supports pagination through query parameters.
875
-
876
- #### `GET /user/:userId`
877
-
878
- - **Description**: Retrieve a specific user by its ID.
879
- - **Authentication**: Required (uses `AuthGuard`).
880
- - **Parameters**:
881
- - **userId** (number): The ID of the user to retrieve.
882
-
883
- #### `POST /user`
884
-
885
- - **Description**: Create a new user.
886
- - **Authentication**: Required (uses `AuthGuard`).
887
- - **Body**:
888
- - **email** (string): Email address of the user.
889
- - **name** (string): Name of the user.
890
- - **password** (string): Password of the user.
891
-
892
- #### `PATCH /user/:userId`
893
-
894
- - **Description**: Update an existing user.
895
- - **Authentication**: Required (uses `AuthGuard`).
896
- - **Parameters**:
897
- - **userId** (number): The ID of the user to update.
898
- - **Body**:
899
- - **email** (string, optional): Updated email address of the user.
900
- - **name** (string, optional): Updated name of the user.
901
- - **password** (string, optional): Updated password of the user.
902
-
903
- #### `DELETE /user`
904
-
905
- - **Description**: Delete one or more user.
906
- - **Authentication**: Required (uses `AuthGuard`).
907
- - **Body**:
908
- - **ids** (number[]): Array of user IDs to delete.
909
-
910
- ### Service Methods
911
-
912
- #### `getUsers(paginationParams: PaginationDTO)`
913
-
914
- - **Description**: Retrieves a paginated list of user with optional search functionality.
915
- - **Parameters**:
916
- - **paginationParams**: Includes pagination and search criteria.
917
-
918
- #### `get(userId: number)`
919
-
920
- - **Description**: Retrieves a specific user by its ID.
921
- - **Parameters**:
922
- - **userId**: ID of the user to retrieve.
923
-
924
- #### `hashPassword(password: string): Promise<string>`
925
-
926
- - **Description**: Hashes a password using bcrypt.
927
- - **Parameters**:
928
- - **password**: The password to be hashed.
929
-
930
- #### `create(data: CreateDTO)`
931
-
932
- - **Description**: Creates a new user.
933
- - **Parameters**:
934
- - **data**: Includes email, name, and password.
935
-
936
- #### `update(id: number, data: UpdateDTO)`
937
-
938
- - **Description**: Updates an existing user.
939
- - **Parameters**:
940
- - **id**: ID of the user to update.
941
- - **data**: Includes updated email, name, and password.
942
-
943
- #### `delete(data: DeleteDTO)`
944
-
945
- - **Description**: Deletes one or more user.
946
- - **Parameters**:
947
- - **data**: Includes array of user IDs to delete.
948
-
949
- ### Folder Structure
950
-
951
- ```plaintext
952
- ├── constants/
953
- │ └── user.constants.ts # Constants related to user module
954
- ├── dto/
955
- │ ├── create.dto.ts # Data Transfer Object for creating a user
956
- │ └── update.dto.ts # Data Transfer Object for updating a user
957
- ├── user.module.ts # Module for UserService
958
- ├── user.controller.ts # Controller for user-related endpoints
959
- └── user.service.ts # Service handling business logic for user
960
- ```
1
+ # <p align="center">hedhog/admin</p>
2
+
3
+ <p align="center">
4
+ <img src="https://avatars.githubusercontent.com/u/177489127?s=200&v=4" alt="Hedhog Avatar" />
5
+ </p>
6
+
7
+ ## Table of Contents
8
+
9
+ - [Overview](#overview)
10
+ - [Hedhog Auth](#hedhog-auth)
11
+ - [Hedhog Locale](#hedhog-locale)
12
+ - [Hedhog Menu](#hedhog-menu)
13
+ - [Hedhog Role](#hedhog-role)
14
+ - [Hedhog Route](#hedhog-route)
15
+ - [Hedhog Screen](#hedhog-screen)
16
+ - [Hedhog Setting](#hedhog-setting)
17
+ - [Hedhog User](#hedhog-user)
18
+
19
+ # Overview
20
+
21
+ The **Hedhog Admin** module is a collection of core modules essential for managing and administering applications within the HedHog framework. It brings together various modules that provide key functionalities such as authentication, menu configuration, permissions, screen management and user management.
22
+
23
+ Whether you need to secure access to resources, manage user role, or handle file uploads, the `@hedhog/admin` module provides everything required to manage a modern web application’s backend with minimal setup.
24
+
25
+ ### Included Modules<
26
+
27
+ - **@hedhog/auth**: Provides authentication and authorization mechanisms, ensuring secure access to application resources.
28
+ - **@hedhog/locale**: Provides solution for managing locale and translation across applications.
29
+ - **@hedhog/menu**: Allows for the creation and management of dynamic menu within the application interface.
30
+ - **@hedhog/role**: Facilitates the management of role, controlling access to specific features or areas.
31
+ - **@hedhog/route**: Provides a comprehensive system for managing route within your application.
32
+ - **@hedhog/setting**: Provides a solution for managing application setting.
33
+ - **@hedhog/screen**: Provides a structure for managing different screens and UI components.
34
+ - **@hedhog/user**: Manages user accounts, including creation, updates, and deletion, along with password encryption and secure access.
35
+
36
+ ### Installation
37
+
38
+ To install the `@hedhog/admin` module, use npm:
39
+
40
+ ```bash
41
+ npm install @hedhog/admin
42
+ ```
43
+
44
+ ### Usage
45
+
46
+ The `@hedhog/admin` module acts as a base for administrative tasks in HedHog applications. Once installed, you can integrate the included modules into your project to quickly set up and manage essential features for your admin interface.
47
+
48
+ ```typescript
49
+ import { AdminModule } from '@hedhog/admin';
50
+
51
+ @Module({
52
+ imports: [AdminModule],
53
+ })
54
+ export class AppModule {}
55
+ ```
56
+
57
+ By importing the AdminModule, you gain access to all the functionality provided by the individual modules, making it easier to manage authentication, permissions, user, and more.
58
+
59
+ ---
60
+
61
+ # Hedhog Auth
62
+
63
+ **HedHog Auth** is a library designed to handle authentication tasks within the HedHog framework. It provides functionalities for user login, token management, multi-factor authentication (MFA), and password reset, ensuring secure and reliable user authentication processes.
64
+
65
+ ### Features
66
+
67
+ - **Token Verification**: Verify authentication tokens for user.
68
+ - **Login**: Authenticate user with email and password, and handle multi-factor authentication if required.
69
+ - **OTP Management**: Manage one-time passwords (OTP) for multi-factor authentication.
70
+ - **Password Reset**: Facilitate password reset requests through email.
71
+
72
+ #### Controller
73
+
74
+ The `AuthController` defines the following endpoints:
75
+
76
+ - `GET /auth/verify`: Verify the authentication status of the user.
77
+ - `POST /auth/login`: Authenticate a user using email and password.
78
+ - `POST /auth/otp`: Verify an OTP code for multi-factor authentication.
79
+ - `POST /auth/forget`: Request a password reset link via email.
80
+
81
+ #### AuthService
82
+
83
+ The `AuthService` provides methods for:
84
+
85
+ - `verifyToken(token: string)`: Verify the provided JWT token.
86
+ - `generateRandomString(length: number)`: Generate a random string of specified length.
87
+ - `generateRandomNumber()`: Generate a random 6-digit number.
88
+ - `loginWithEmailAndPassword(email: string, password: string)`: Authenticate user with email and password and handle multi-factor authentication if required.
89
+ - `getToken(user)`: Generate a JWT token for the authenticated user.
90
+ - `forget({ email }: ForgetDTO)`: Initiate a password reset process for the specified email.
91
+ - `otp({ token, code }: OtpDTO)`: Verify the OTP code provided by the user.
92
+
93
+ ### Folder Structure
94
+
95
+ ```plaintext
96
+ ├── auth.controller.ts # Defines route for authentication
97
+ ├── auth.service.ts # Contains authentication logic
98
+ ├── auth.service.spec.ts # Testing file for auth service
99
+ ├── auth.module.ts # Authentication module
100
+ ├── dto/
101
+ │ ├── forget.dto.ts # Data Transfer Object for password reset
102
+ │ ├── login.dto.ts # Data Transfer Object for login
103
+ │ └── otp.dto.ts # Data Transfer Object for OTP verification
104
+ ├── decorators/
105
+ │ ├── public.decorator.ts # Custom decorator to mark public route
106
+ │ └── user.decorator.ts # Custom decorator to get user from request
107
+ ├── types/
108
+ │ └── user.type.ts # Type definitions for user-related data
109
+ ├── enums/
110
+ │ └── multifactor-type.enum.ts # Enumeration for multi-factor authentication types
111
+ ├── guards/
112
+ │ └── auth.guard.ts # Guard for protecting route
113
+ ```
114
+
115
+ ---
116
+
117
+ # Hedhog Locale
118
+
119
+ **Hedhog Locale** module provides a powerful solution for managing locale and translation across applications. It includes functionalities to retrieve, create, update, and delete locale data, with support for pagination and localization. The module integrates seamlessly within the HedHog ecosystem, using @hedhog/pagination for handling paginated responses and @hedhog/prisma for database interactions.
120
+
121
+ ### Controller Endpoints
122
+
123
+ #### `GET /locale/system/enables`
124
+
125
+ - **Description**: Retrieve a paginated list of enabled locale.
126
+ - **Authentication**: Not required (public endpoint).
127
+ - **Parameters**:
128
+ - `locale (string)`: Locale code for filtering.
129
+ - Pagination parameters (optional).
130
+
131
+ #### `GET /locale/:localeCode/:namespace`
132
+
133
+ - **Description**: Retrieve translation for a specific locale and namespace.
134
+ - **Authentication**: Not required (public endpoint).
135
+ - **Parameters**:
136
+ - `localeCode (string)`: The locale code to fetch translation for.
137
+ - `namespace (string)`: The namespace to fetch translation from.
138
+
139
+ #### `GET /locale`
140
+
141
+ - **Description**: Retrieve a paginated list of locale.
142
+ - **Authentication**: Required.
143
+ - **Pagination**: Supports pagination through query parameters.
144
+
145
+ #### `GET /locale/:id`
146
+
147
+ - **Description**: Retrieve a specific locale by its ID.
148
+ - **Authentication**: Required.
149
+ - **Parameters**:
150
+ - `id (number)`: The ID of the locale to retrieve.
151
+
152
+ #### `POST /locale`
153
+
154
+ - **Description**: Create a new locale entry.
155
+ - **Authentication**: Required.
156
+ - **Body**:
157
+ - `code (string)`: The code of the locale.
158
+ - `region (string)`: The region of the locale.
159
+
160
+ #### `PATCH /locale/:id`
161
+
162
+ - **Description**: Update an existing locale entry.
163
+ - **Authentication**: Required.
164
+ - **Parameters**:
165
+ - `id (number)`: The ID of the locale to update.
166
+ - **Body**:
167
+ - `code (string, optional)`: Updated code of the locale.
168
+ - `region (string, optional)`: Updated region of the locale.
169
+
170
+ #### `DELETE /locale`
171
+
172
+ - **Description**: Delete one or more locale.
173
+ - **Authentication**: Required.
174
+ - **Body**:
175
+ - `ids (number[])`: Array of locale IDs to delete.
176
+
177
+ ### Service Methods
178
+
179
+ #### `getEnables(locale: string, paginationParams: PaginationDTO)`
180
+
181
+ - **Description**: Retrieves a paginated list of enabled locale based on locale code and pagination parameters.
182
+ - **Parameters**:
183
+ - `locale (string)`: Locale code for filtering.
184
+ - `paginationParams (PaginationDTO)`: Includes pagination criteria.
185
+
186
+ #### `getTranslations(localeCode: string, namespace: string)`
187
+
188
+ - **Description**: Retrieves translation for a given locale code and namespace.
189
+ - **Parameters**:
190
+ - `localeCode (string)`: The locale code to fetch translation for.
191
+ - `namespace (string)`: The namespace to fetch translation from.
192
+
193
+ #### `get(paginationParams: PaginationDTO)`
194
+
195
+ - **Description**: Retrieves a paginated list of all locale.
196
+ - **Parameters**:
197
+ - `paginationParams (PaginationDTO)`: Includes pagination criteria.
198
+
199
+ #### `getById(localeId: number)`
200
+
201
+ - **Description**: Retrieves a specific locale by its ID.
202
+ - **Parameters**:
203
+ - `localeId (number)`: ID of the locale to retrieve.
204
+
205
+ #### `create(data: CreateDTO)`
206
+
207
+ - **Description**: Creates a new locale entry.
208
+ - **Parameters**:
209
+ - `data (CreateDTO)`: Includes code and region of the new locale.
210
+
211
+ #### `update(id: number, data: UpdateDTO)`
212
+
213
+ - **Description**: Updates an existing locale entry.
214
+ - **Parameters**:
215
+ - `id (number)`: ID of the locale to update.
216
+ - `data (UpdateDTO)`: Includes updated code and region.
217
+
218
+ #### `delete(data: DeleteDTO)`
219
+
220
+ - **Description**: Deletes one or more locale entries.
221
+ - **Parameters**:
222
+ - `data (DeleteDTO)`: Includes array of IDs to delete.
223
+
224
+ ### Folder Structure
225
+
226
+ ```plaintext
227
+ |── dto/ # Data Transfer Objects
228
+ │ ├── create.dto.ts # DTO for creating locale
229
+ │ ├── delete.dto.ts # DTO for deleting locale
230
+ │ └── update.dto.ts # DTO for updating locale
231
+ |── locale.controller.ts # Controller for locale
232
+ |── locale.decorator.ts # Decorator for injecting locale into requests
233
+ |── locale.middleware.ts # Middleware to handle locale-specific processing
234
+ |── locale.module.ts # Module definition for locale
235
+ |── locale.service.ts # Service class for locale logic
236
+ ├── locale.service.spec.ts # Testing file for locale service
237
+ |── index.ts # Main export file for the module
238
+ ```
239
+
240
+ ---
241
+
242
+ # Hedhog Menu
243
+
244
+ **HedHog Menu** is a library for managing menu within the HedHog framework. It provides a set of RESTful endpoints for CRUD operations on menu items, as well as functionalities to handle pagination and ordering of menu.
245
+
246
+ ### Features
247
+
248
+ - **CRUD Operations**: Create, Read, Update, and Delete menu items.
249
+ - **Pagination**: Paginate menu items for efficient data retrieval.
250
+ - **Ordering**: Update the order of menu items.
251
+
252
+ ### MenuController
253
+
254
+ The `MenuController` exposes the following endpoints:
255
+
256
+ - **GET /menu**: Retrieve a list of menu with pagination.
257
+ - **GET /menu/:menuId**: Retrieve a specific menu by ID.
258
+ - **POST /menu**: Create a new menu item.
259
+ - **PATCH /menu/:menuId**: Update an existing menu item by ID.
260
+ - **DELETE /menu**: Delete menu items based on provided IDs.
261
+ - **PATCH /menu/order**: Update the order of menu items.
262
+
263
+ ### MenuService
264
+
265
+ The `MenuService` class contains the business logic for handling menu operations, including querying the database and processing data.
266
+
267
+ - **getMenu(paginationParams: PaginationDTO)**: Retrieves a paginated list of menu items.
268
+ - **get(menuId: number)**: Retrieves a menu item by ID.
269
+ - **create(data: CreateDTO)**: Creates a new menu item.
270
+ - **update({ id, data }: { id: number; data: UpdateDTO })**: Updates an existing menu item by ID.
271
+ - **delete(data: DeleteDTO)**: Deletes menu items based on provided IDs.
272
+ - **updateOrder(data: OrderDTO)**: Updates the order of menu items.
273
+
274
+ ### Folder Structure
275
+
276
+ ```plaintext
277
+ ├── menu.controller.ts # Handles HTTP requests related to menu
278
+ ├── menu.service.ts # Contains business logic for menu operations
279
+ ├── menu.service.spec.ts # Testing file for menu service
280
+ ├── menu.module.ts # Module definition for menu functionalities
281
+ ├── dto/
282
+ │ ├── create.dto.ts # Data Transfer Object for creating a menu
283
+ │ ├── update.dto.ts # Data Transfer Object for updating a menu
284
+ └── order.dto.ts # Data Transfer Object for updating menu order
285
+ ```
286
+
287
+ ---
288
+
289
+ # Hedhog Role
290
+
291
+ **HedHog Role** module is designed to handle role management within the HedHog framework. It allows for creating, updating, and deleting role and managing their relationships with user, menu, route, and screens.
292
+
293
+ ### Features
294
+
295
+ - **Role Management**: Create, update, and delete role.
296
+ - **User Associations**: Assign and manage user associated with role.
297
+ - **Menu, Route, and Screen Associations**: Manage the association between role and menu, route, or screens.
298
+ - **Pagination**: Handle paginated responses for all resources.
299
+
300
+ ### Controller Endpoints
301
+
302
+ #### `GET /role`
303
+
304
+ - **Description**: Retrieve a paginated list of all role.
305
+ - **Authentication**: Required (uses `AuthGuard`).
306
+ - **Parameters**:
307
+ - `paginationParams` (optional): Standard pagination parameters.
308
+
309
+ #### `GET /role/:roleId`
310
+
311
+ - **Description**: Retrieve details of a specific role.
312
+ - **Authentication**: Required (uses `AuthGuard`).
313
+ - **Parameters**:
314
+ - `roleId (number)`: The ID of the role to retrieve.
315
+
316
+ #### `POST /role`
317
+
318
+ - **Description**: Create a new role.
319
+ - **Authentication**: Required (uses `AuthGuard`).
320
+ - **Parameters**:
321
+ - `data` (CreateDTO): The data for the new role (name, description, etc).
322
+
323
+ #### `PATCH /role/:roleId`
324
+
325
+ - **Description**: Update an existing role.
326
+ - **Authentication**: Required (uses `AuthGuard`).
327
+ - **Parameters**:
328
+ - `roleId (number)`: The ID of the role to update.
329
+ - `data` (UpdateDTO): The data to update for the role.
330
+
331
+ #### `DELETE /role`
332
+
333
+ - **Description**: Delete one or more role.
334
+ - **Authentication**: Required (uses `AuthGuard`).
335
+ - **Parameters**:
336
+ - `data` (DeleteDTO): List of role IDs to delete.
337
+
338
+ #### `GET /role/:roleId/user`
339
+
340
+ - **Description**: Get a list of user associated with a specific role.
341
+ - **Authentication**: Required (uses `AuthGuard`).
342
+ - **Parameters**:
343
+ - `roleId (number)`: The ID of the role to retrieve user for.
344
+ - `paginationParams` (optional): Standard pagination parameters.
345
+
346
+ #### `GET /role/:roleId/menu`
347
+
348
+ - **Description**: Get a list of menu associated with a specific role.
349
+ - **Authentication**: Required (uses `AuthGuard`).
350
+ - **Parameters**:
351
+ - `roleId (number)`: The ID of the role to retrieve menu for.
352
+ - `paginationParams` (optional): Standard pagination parameters.
353
+
354
+ #### `GET /role/:roleId/route`
355
+
356
+ - **Description**: Get a list of route associated with a specific role.
357
+ - **Authentication**: Required (uses `AuthGuard`).
358
+ - **Parameters**:
359
+ - `roleId (number)`: The ID of the role to retrieve route for.
360
+ - `paginationParams` (optional): Standard pagination parameters.
361
+
362
+ #### `GET /role/:roleId/screens`
363
+
364
+ - **Description**: Get a list of screens associated with a specific role.
365
+ - **Authentication**: Required (uses `AuthGuard`).
366
+ - **Parameters**:
367
+ - `roleId (number)`: The ID of the role to retrieve screens for.
368
+ - `paginationParams` (optional): Standard pagination parameters.
369
+
370
+ #### `PATCH /role/:roleId/user`
371
+
372
+ - **Description**: Update the user associated with a specific role.
373
+ - **Authentication**: Required (uses `AuthGuard`).
374
+ - **Parameters**:
375
+ - `roleId (number)`: The ID of the role. -`data` (UpdateIdsDTO): List of user IDs to associate with the role.
376
+
377
+ #### `PATCH /role/:roleId/menu`
378
+
379
+ - **Description**: Update the menu associated with a specific role.
380
+ - **Authentication**: Required (uses `AuthGuard`).
381
+ - **Parameters**:
382
+ - `roleId (number)`: The ID of the role.
383
+ - `data` (UpdateIdsDTO): List of menu IDs to associate with the role.
384
+
385
+ #### `PATCH /role/:roleId/route`
386
+
387
+ - **Description**: Update the route associated with a specific role.
388
+ - **Authentication**: Required (uses `AuthGuard`).
389
+ - **Parameters**:
390
+ - `roleId (number)`: The ID of the role.
391
+ - `data` (UpdateIdsDTO): List of route IDs to associate with the role.
392
+
393
+ #### `PATCH /role/:roleId/screens`
394
+
395
+ - **Description**: Update the screens associated with a specific role.
396
+ - **Authentication**: Required (uses `AuthGuard`).
397
+ - **Parameters**:
398
+ - `roleId (number)`: The ID of the role.
399
+ - `data` (UpdateIdsDTO): List of screen IDs to associate with the role.
400
+
401
+ ### Service Methods
402
+
403
+ #### `updateUsers(roleId: number, { ids }: UpdateIdsDTO)`
404
+
405
+ - **Description**: Updates the user associated with a specific role by deleting existing associations and creating new ones.
406
+ - **Parameters**:
407
+ - `roleId (number)`: The ID of the role to update.
408
+ - `data`: An object containing an array of user IDs to associate with the role.
409
+
410
+ #### `updateScreens(roleId: number, data: UpdateIdsDTO)`
411
+
412
+ - **Description**: Updates the screens associated with a specific role by deleting existing associations and creating new ones.
413
+ - **Parameters**:
414
+ - `roleId (number)`: The ID of the role to update.
415
+ - `data`: An object containing an array of screen IDs to associate with the role.
416
+
417
+ #### `updateRoutes(roleId: number, data: UpdateIdsDTO)`
418
+
419
+ - **Description**: Updates the route associated with a specific role by deleting existing associations and creating new ones.
420
+ - **Parameters**:
421
+ - `roleId (number)`: The ID of the role to update.
422
+ - `data`: An object containing an array of route IDs to associate with the role.
423
+
424
+ #### `updateMenus(roleId: number, data: UpdateIdsDTO)`
425
+
426
+ - **Description**: Updates the menu associated with a specific role by deleting existing associations and creating new ones.
427
+ - **Parameters**:
428
+ - `roleId (number)`: The ID of the role to update.
429
+ - `data`: An object containing an array of menu IDs to associate with the role.
430
+
431
+ #### `listUsers(roleId: number, paginationParams: PaginationDTO)`
432
+
433
+ - **Description**: Retrieves a paginated list of user associated with a specific role.
434
+ - **Parameters**:
435
+ - `roleId (number)`: The ID of the role to retrieve associated user.
436
+ - `paginationParams`: Includes pagination criteria.
437
+
438
+ #### `listMenus(roleId: number, paginationParams: PaginationDTO)`
439
+
440
+ - **Description**: Retrieves a paginated list of menu associated with a specific role.
441
+ - **Parameters**:
442
+ - `roleId (number)`: The ID of the role to retrieve associated menu.
443
+ - `paginationParams`: Includes pagination criteria.
444
+
445
+ #### `listRoutes(roleId: number, paginationParams: PaginationDTO)`
446
+
447
+ - **Description**: Retrieves a paginated list of route associated with a specific role.
448
+ - **Parameters**:
449
+ - `roleId (number)`: The ID of the role to retrieve associated route.
450
+ - `paginationParams`: Includes pagination criteria.
451
+
452
+ #### `listScreens(roleId: number, paginationParams: PaginationDTO)`
453
+
454
+ - **Description**: Retrieves a paginated list of screens associated with a specific role.
455
+ - **Parameters**:
456
+ - `roleId (number)`: The ID of the role to retrieve associated screens.
457
+ - `paginationParams`: Includes pagination criteria.
458
+
459
+ #### `getRoles(paginationParams: PaginationDTO)`
460
+
461
+ - **Description**: Retrieves a paginated list of all role, with optional search functionality based on name and description.
462
+ - **Parameters**:
463
+ - `paginationParams`: Includes pagination and search criteria.
464
+
465
+ #### `get(roleId: number)`
466
+
467
+ - **Description**: Retrieves a specific role by its ID.
468
+ - **Parameters**:
469
+ - `roleId (number)`: The ID of the role to retrieve.
470
+
471
+ #### `create(data: CreateDTO)`
472
+
473
+ - **Description**: Creates a new role with the specified name and description.
474
+ - **Parameters**:
475
+ - `data`: An object containing the following properties:
476
+ - `name (string)`: The name of the new role.
477
+ - `description (string)`: A description of the new role.
478
+
479
+ #### `update({ id, data }: { id: number; data: UpdateDTO })`
480
+
481
+ - **Description**: Updates an existing role identified by its ID.
482
+ - **Parameters**:
483
+ - `id (number)`: The ID of the role to update.
484
+ - `data`: An object containing the updated information for the role, defined in UpdateDTO.
485
+
486
+ #### `delete({ ids }: DeleteDTO)`
487
+
488
+ - **Description**: Deletes one or more role identified by their IDs.
489
+ - **Parameters**:
490
+ - `ids (array of number)`: An array containing the IDs of the role to delete.
491
+
492
+ ### Folder Structure
493
+
494
+ ```plaintext
495
+ ├── decorators/
496
+ │ ├── role.decorator.ts # Custom decorator for role
497
+ ├── dto/ # Data Transfer Objects
498
+ │ ├── create.dto.ts # DTO for creating a role
499
+ │ ├── update.dto.ts # DTO for updating a role
500
+ ├── guards/
501
+ │ └── role.guard.ts # Guard for role
502
+ ├── role.controller.ts # Handles HTTP requests related to role
503
+ ├── role.module.ts # Module definition for the role
504
+ └── role.service.ts # Service class for role-related logic
505
+ └── role.service.spec.ts # Testing file for role service
506
+ ```
507
+
508
+ ---
509
+
510
+ # Hedhog Route
511
+
512
+ **Hedhog Route** module provides a comprehensive system for managing route within your application. It allows administrators to define, modify, and control access to different route within the application. The module also integrates with other Hedhog modules to ensure that permissions and role are respected when accessing route.
513
+
514
+ ### Features
515
+
516
+ - **CRUD Operations**: Create, Read, Update, and Delete route.
517
+ - **Route Management**: Manage application route, including their accessibility and assignment to user role.
518
+ - **Permissions Integration**: Integrates with Hedhog Permission to control access to specific route based on user role.
519
+
520
+ ### Controller Endpoints
521
+
522
+ #### `GET /route`
523
+
524
+ - **Description**: Retrieves a paginated list of all route.
525
+ - **Authentication**: Required (uses `AuthGuard`).
526
+ - **Parameters**:
527
+ - `paginationParams`: Includes pagination criteria.
528
+
529
+ #### `GET /route/:routeId`
530
+
531
+ - **Description**: Retrieves a specific route by its ID.
532
+ - **Authentication**: Required (uses `AuthGuard`).
533
+ - **Parameters**:
534
+ - `routeId (number)`: The ID of the route to retrieve.
535
+
536
+ #### `POST /route`
537
+
538
+ - **Description**: Creates a new route with the specified URL and method.
539
+ - **Authentication**: Required (uses `AuthGuard`).
540
+ - **Parameters**:
541
+ - `data`: An object containing the url and method for the new route.
542
+
543
+ #### `PATCH /route/:routeId`
544
+
545
+ - **Description**: Updates an existing route identified by its ID.
546
+ - **Authentication**: Required (uses `AuthGuard`).
547
+ - **Parameters**:
548
+ - `routeId (number)`: The ID of the route to update.
549
+ - `data`: An object containing the updated information for the route.
550
+
551
+ #### `DELETE /route`
552
+
553
+ - **Description**: Deletes one or more route.
554
+ - **Authentication**: Required (uses `AuthGuard`).
555
+ - **Parameters**:
556
+ - `data`: An object containing an array of route IDs to delete.
557
+
558
+ #### `GET /route/:routeId/role`
559
+
560
+ - **Description**: Retrieves a paginated list of role associated with a specific route.
561
+ - **Authentication**: Required (uses `AuthGuard`).
562
+ - **Parameters**:
563
+ - `routeId (number)`: The ID of the route to retrieve associated role.
564
+ - `paginationParams`: Includes pagination criteria.
565
+
566
+ #### `PATCH /route/:routeId/role`
567
+
568
+ - **Description**: Updates the role associated with a specific route.
569
+ - **Authentication**: Required (uses `AuthGuard`).
570
+ - **Parameters**:
571
+ - `routeId (number)`: The ID of the route.
572
+ - `data`: An object containing an array of role IDs to associate with the route.
573
+
574
+ #### `GET /route/:routeId/screens`
575
+
576
+ - **Description**: Retrieves a paginated list of screens associated with a specific route.
577
+ - **Authentication**: Required (uses `AuthGuard`).
578
+ - **Parameters**:
579
+ - `routeId (number)`: The ID of the route to retrieve associated screens.
580
+ - `paginationParams`: Includes pagination criteria.
581
+
582
+ #### `PATCH /route/:routeId/screens`
583
+
584
+ - **Description:** Updates the screens associated with a specific route.
585
+ - **Authentication**: Required (uses AuthGuard).
586
+ - **Parameters**:
587
+ - `routeId (number)`: The ID of the route.
588
+ - `data`: An object containing an array of screen IDs to associate with the route.
589
+
590
+ ### Service Methods
591
+
592
+ #### `getRoutes(paginationParams: PaginationDTO)`
593
+
594
+ - **Description**: Retrieves a paginated list of route with optional search functionality based on URL and method.
595
+ - **Parameters**:
596
+ - `paginationParams`: Includes pagination and search criteria.
597
+
598
+ #### `getRouteById(routeId: number)`
599
+
600
+ - **Description**: Retrieves a specific route by its ID.
601
+ - **Parameters**:
602
+ - `routeId`: The ID of the route to retrieve.
603
+
604
+ #### `create(data: CreateDTO)`
605
+
606
+ - **Description**: Creates a new route with the specified URL and method.
607
+ - **Parameters**:
608
+ - `data`: An object containing the URL and method for the new route.
609
+
610
+ #### `update({ id, data }: { id: number; data: UpdateDTO })`
611
+
612
+ - **Description**: Updates an existing route identified by its ID.
613
+ - **Parameters**:
614
+ - `id`: The ID of the route to update.
615
+ - `data`: An object containing the updated information for the route.
616
+
617
+ #### `delete({ ids }: DeleteDTO)`
618
+
619
+ - **Description**: Deletes one or more route identified by their IDs.
620
+ - **Parameters**:
621
+ - `ids`: An object containing an array of route IDs to delete.
622
+
623
+ #### `listRoles(routeId: number, paginationParams: PaginationDTO)`
624
+
625
+ - **Description**: Retrieves a paginated list of role associated with a specific route.
626
+ - **Parameters**:
627
+ - `routeId`: The ID of the route to retrieve associated role.
628
+ - `paginationParams`: Includes pagination parameters.
629
+
630
+ #### `updateRoles(routeId: number, data: UpdateIdsDTO)`
631
+
632
+ - **Description**: Updates the role associated with a specific route.
633
+ - **Parameters**:
634
+ - `routeId`: The ID of the route.
635
+ - `data`: An object containing an array of role IDs to associate with the route.
636
+
637
+ #### `listScreens(routeId: number, paginationParams: PaginationDTO)`
638
+
639
+ - **Description**: Retrieves a paginated list of screens associated with a specific route.
640
+ - **Parameters**:
641
+ - `routeId`: The ID of the route to retrieve associated screens.
642
+ - `paginationParams`: Includes pagination parameters.
643
+
644
+ #### `updateScreens(routeId: number, data: UpdateIdsDTO)`
645
+
646
+ - **Description**: Updates the screens associated with a specific route.
647
+ - **Parameters**:
648
+ - `routeId`: The ID of the route.
649
+ - `data`: An object containing an array of screen IDs to associate with the route.
650
+
651
+ ### Folder Structure
652
+
653
+ ```plaintext
654
+ ├── dto/ # Data Transfer Objects
655
+ │ ├── create.dto.ts # DTO for creating a route
656
+ │ ├── update.dto.ts # DTO for updating a route
657
+ ├── guards/
658
+ │ └── route.guard.ts # Guard for route
659
+ ├── route.controller.ts # Handles HTTP requests related to route
660
+ ├── route.module.ts # Module definition for the route
661
+ ├── route.service.ts # Service class for route-related logic
662
+ └── route.service.spec.ts # Testing file for route service
663
+ ```
664
+
665
+ ---
666
+
667
+ # Hedhog Setting
668
+
669
+ **Hedhog Setting** module provides a comprehensive solution for managing application setting. It includes functionalities to create, read, update, and delete setting, along with support for pagination and search capabilities. This module integrates with the HedHog ecosystem, utilizing @hedhog/pagination for managing paginated results and @hedhog/prisma for database interactions.
670
+
671
+ ### Controller Endpoints
672
+
673
+ #### `GET /setting`
674
+
675
+ - **Description**: Retrieve a paginated list of setting.
676
+ - **Authentication**: Required (uses `AuthGuard`).
677
+ - **Pagination**: Supports pagination through query parameters.
678
+
679
+ #### `GET /setting/:settingId`
680
+
681
+ - **Description**: Retrieve a specific setting by its ID.
682
+ - **Authentication**: Required (uses AuthGuard).
683
+ - **Parameters**:
684
+ - **settingId** (number): The ID of the setting to retrieve.
685
+
686
+ #### `POST /setting`
687
+
688
+ - **Description**: Create a new setting.
689
+ - **Authentication**: Required (uses AuthGuard).
690
+ - **Body**:
691
+ - **name** (string): Name of the setting.
692
+
693
+ #### `PATCH /setting/:settingId`
694
+
695
+ - **Description**: Update an existing setting.
696
+ - **Authentication**: Required (uses AuthGuard).
697
+ - **Parameters**:
698
+ - **settingId** (number): The ID of the setting to update.
699
+ - **Body**:
700
+ - **name** (string, optional): Updated name of the setting.
701
+
702
+ #### `DELETE /setting`
703
+
704
+ - **Description**: Delete one or more setting.
705
+ - **Authentication**: Required (uses AuthGuard).
706
+ - **Body**:
707
+ - **ids** (number[]): Array of setting IDs to delete.
708
+
709
+ ### Service Methods
710
+
711
+ #### `getSettings(paginationParams: PaginationDTO)`
712
+
713
+ - **Description**: Retrieves a paginated list of setting with optional search functionality.
714
+ - **Parameters**:
715
+ - **paginationParams**: Includes pagination and search criteria.
716
+
717
+ #### `get(settingId: number)`
718
+
719
+ - **Description**: Retrieves a specific setting by its ID.
720
+ - **Parameters**:
721
+ - **settingId**: ID of the setting to retrieve.
722
+
723
+ #### `create(data: CreateDTO)`
724
+
725
+ - **Description**: Creates a new setting.
726
+ - **Parameters**:
727
+ - **data**: Includes name of the setting.
728
+
729
+ #### `update(id: number, data: UpdateDTO)`
730
+
731
+ - **Description**: Updates an existing setting.
732
+ - **Parameters**:
733
+ - **id**: ID of the setting to update.
734
+ - **data**: Includes updated name of the setting.
735
+
736
+ #### `delete(data: DeleteDTO)`
737
+
738
+ - **Description**: Deletes one or more setting.
739
+ - **Parameters**:
740
+ - **data**: Includes array of ids to delete.
741
+
742
+ ## Folder Structure
743
+
744
+ ```plaintext
745
+ |── dto/ # Data Transfer Objects
746
+ │ |── create.dto.ts # DTO for creating setting
747
+ │ |── delete.dto.ts # DTO for deleting setting
748
+ │ |── update.dto.ts # DTO for updating setting
749
+ |── setting.controller.ts # Controller for setting
750
+ |── setting.module.ts # Module definition for setting
751
+ |── setting.service.ts # Service class for setting logic
752
+ |── setting.service.spec.ts # Testing file for setting service
753
+ ```
754
+
755
+ ---
756
+
757
+ # Hedhog Screen
758
+
759
+ **Hedhog Screen** module is part of the HedHog framework and provides functionalities for managing screens in your application. It offers a set of RESTful API endpoints and service methods to handle CRUD operations and pagination for screens.
760
+
761
+ ### Features
762
+
763
+ - Create, Read, Update, and Delete (**CRUD**) operations for screens.
764
+ - **Pagination** for listing screens.
765
+ - **Search** functionality to filter screens based on various attributes.
766
+
767
+ ### Controller Endpoints
768
+
769
+ #### `GET /screens`
770
+
771
+ - **Description**: Retrieve a paginated list of screens.
772
+ - **Authentication**: Required (uses `AuthGuard`).
773
+ - **Pagination**: Supports pagination through query parameters.
774
+
775
+ #### `GET /screens/:screenId`
776
+
777
+ - **Description**: Retrieve a specific screen by its ID.
778
+ - **Authentication**: Required (uses `AuthGuard`).
779
+ - **Parameters**:
780
+ - `screenId` (number): The ID of the screen to retrieve.
781
+
782
+ #### `POST /screens`
783
+
784
+ - **Description**: Create a new screen.
785
+ - **Authentication**: Required (uses `AuthGuard`).
786
+ - **Body**:
787
+ - `name` (string): Name of the screen.
788
+ - `slug` (string): Unique identifier for the screen.
789
+ - `description` (string): Description of the screen.
790
+ - `icon` (string): Icon associated with the screen.
791
+
792
+ #### `PATCH /screens/:screenId`
793
+
794
+ - **Description**: Update an existing screen.
795
+ - **Authentication**: Required (uses `AuthGuard`).
796
+ - **Parameters**:
797
+ - `screenId` (number): The ID of the screen to update.
798
+ - **Body**:
799
+ - `name` (string, optional): Updated name of the screen.
800
+ - `slug` (string, optional): Updated slug of the screen.
801
+ - `description` (string, optional): Updated description of the screen.
802
+ - `icon` (string, optional): Updated icon of the screen.
803
+
804
+ #### `DELETE /screens`
805
+
806
+ - **Description**: Delete one or more screens.
807
+ - **Authentication**: Required (uses `AuthGuard`).
808
+ - **Body**:
809
+ - `ids` (number[]): Array of screen IDs to delete.
810
+
811
+ ### Service Methods
812
+
813
+ #### `getScreens(paginationParams: PaginationDTO)`
814
+
815
+ - **Description**: Retrieves a paginated list of screens with optional search functionality.
816
+ - **Parameters**:
817
+ - `paginationParams`: Includes pagination and search criteria.
818
+
819
+ #### `get(screenId: number)`
820
+
821
+ - **Description**: Retrieves a specific screen by its ID.
822
+ - **Parameters**:
823
+ - `screenId`: ID of the screen to retrieve.
824
+
825
+ #### `create(data: CreateDTO)`
826
+
827
+ - **Description**: Creates a new screen.
828
+ - **Parameters**:
829
+ - `data`: Includes `name`, `slug`, `description`, and `icon`.
830
+
831
+ #### `update(id: number, data: UpdateDTO)`
832
+
833
+ - **Description**: Updates an existing screen.
834
+ - **Parameters**:
835
+ - `id`: ID of the screen to update.
836
+ - `data`: Includes updated `name`, `slug`, `description`, and `icon`.
837
+
838
+ #### `delete(data: DeleteDTO)`
839
+
840
+ - **Description**: Deletes one or more screens.
841
+ - **Parameters**:
842
+ - `data`: Includes array of `ids` to delete.
843
+
844
+ ### Folder Structure
845
+
846
+ ```plaintext
847
+ ├── dto/ # Data Transfer Objects
848
+ │ ├── create.dto.ts # DTO for creating a screen
849
+ │ ├── update.dto.ts # DTO for updating a screen
850
+ ├── screen.controller.ts # Handles HTTP requests related to screens
851
+ ├── screen.module.ts # Module definition for the screen
852
+ └── screen.service.ts # Service class for screen-related logic
853
+ └── screen.service.spec.ts # Testing file for screen service
854
+ ```
855
+
856
+ ---
857
+
858
+ # Hedhog User
859
+
860
+ The **Hedhog User** module in HedHog provides functionality to manage user data within an application. This module leverages the HedHog framework components, including pagination and [**Prisma**](https://www.prisma.io/) integration, to offer a robust user management system.
861
+
862
+ ### Integrations
863
+
864
+ - **Pagination**: Utilizes `@hedhog/pagination` for managing paginated results of user queries.
865
+ - **Database Interaction**: Uses `@hedhog/prisma` to interface with the database for user data management.
866
+ - **Authentication**: Secured with Auth Module from `@hedhog/admin` to ensure that only authorized user can access or modify user data.
867
+
868
+ ### Controller Endpoints
869
+
870
+ #### `GET /user`
871
+
872
+ - **Description**: Retrieve a paginated list of user.
873
+ - **Authentication**: Required (uses `AuthGuard`).
874
+ - **Pagination**: Supports pagination through query parameters.
875
+
876
+ #### `GET /user/:userId`
877
+
878
+ - **Description**: Retrieve a specific user by its ID.
879
+ - **Authentication**: Required (uses `AuthGuard`).
880
+ - **Parameters**:
881
+ - **userId** (number): The ID of the user to retrieve.
882
+
883
+ #### `POST /user`
884
+
885
+ - **Description**: Create a new user.
886
+ - **Authentication**: Required (uses `AuthGuard`).
887
+ - **Body**:
888
+ - **email** (string): Email address of the user.
889
+ - **name** (string): Name of the user.
890
+ - **password** (string): Password of the user.
891
+
892
+ #### `PATCH /user/:userId`
893
+
894
+ - **Description**: Update an existing user.
895
+ - **Authentication**: Required (uses `AuthGuard`).
896
+ - **Parameters**:
897
+ - **userId** (number): The ID of the user to update.
898
+ - **Body**:
899
+ - **email** (string, optional): Updated email address of the user.
900
+ - **name** (string, optional): Updated name of the user.
901
+ - **password** (string, optional): Updated password of the user.
902
+
903
+ #### `DELETE /user`
904
+
905
+ - **Description**: Delete one or more user.
906
+ - **Authentication**: Required (uses `AuthGuard`).
907
+ - **Body**:
908
+ - **ids** (number[]): Array of user IDs to delete.
909
+
910
+ ### Service Methods
911
+
912
+ #### `getUsers(paginationParams: PaginationDTO)`
913
+
914
+ - **Description**: Retrieves a paginated list of user with optional search functionality.
915
+ - **Parameters**:
916
+ - **paginationParams**: Includes pagination and search criteria.
917
+
918
+ #### `get(userId: number)`
919
+
920
+ - **Description**: Retrieves a specific user by its ID.
921
+ - **Parameters**:
922
+ - **userId**: ID of the user to retrieve.
923
+
924
+ #### `hashPassword(password: string): Promise<string>`
925
+
926
+ - **Description**: Hashes a password using bcrypt.
927
+ - **Parameters**:
928
+ - **password**: The password to be hashed.
929
+
930
+ #### `create(data: CreateDTO)`
931
+
932
+ - **Description**: Creates a new user.
933
+ - **Parameters**:
934
+ - **data**: Includes email, name, and password.
935
+
936
+ #### `update(id: number, data: UpdateDTO)`
937
+
938
+ - **Description**: Updates an existing user.
939
+ - **Parameters**:
940
+ - **id**: ID of the user to update.
941
+ - **data**: Includes updated email, name, and password.
942
+
943
+ #### `delete(data: DeleteDTO)`
944
+
945
+ - **Description**: Deletes one or more user.
946
+ - **Parameters**:
947
+ - **data**: Includes array of user IDs to delete.
948
+
949
+ ### Folder Structure
950
+
951
+ ```plaintext
952
+ ├── constants/
953
+ │ └── user.constants.ts # Constants related to user module
954
+ ├── dto/
955
+ │ ├── create.dto.ts # Data Transfer Object for creating a user
956
+ │ └── update.dto.ts # Data Transfer Object for updating a user
957
+ ├── user.module.ts # Module for UserService
958
+ ├── user.controller.ts # Controller for user-related endpoints
959
+ └── user.service.ts # Service handling business logic for user
960
+ ```