bootifyjs 1.2.0 → 1.3.0

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 (123) hide show
  1. package/README.md +1 -1
  2. package/dist/api.d.ts +2 -0
  3. package/dist/api.d.ts.map +1 -1
  4. package/dist/api.js +20 -4
  5. package/dist/api.js.map +1 -1
  6. package/dist/auth/examples/basic-usage.d.ts +2 -1
  7. package/dist/auth/examples/basic-usage.d.ts.map +1 -1
  8. package/dist/auth/examples/basic-usage.js +3 -2
  9. package/dist/auth/examples/basic-usage.js.map +1 -1
  10. package/dist/auth/index.d.ts +6 -8
  11. package/dist/auth/index.d.ts.map +1 -1
  12. package/dist/auth/index.js +11 -11
  13. package/dist/auth/index.js.map +1 -1
  14. package/dist/auth/middleware/AuthMiddleware.js.map +1 -1
  15. package/dist/cache/bootstrap.js +1 -1
  16. package/dist/cache/bootstrap.js.map +1 -1
  17. package/dist/cache/index.d.ts +2 -1
  18. package/dist/cache/index.d.ts.map +1 -1
  19. package/dist/cache/index.js +4 -1
  20. package/dist/cache/index.js.map +1 -1
  21. package/dist/cache/{in-memory-cache.store.d.ts → stores/in-memory-cache.store.d.ts} +1 -1
  22. package/dist/cache/stores/in-memory-cache.store.d.ts.map +1 -0
  23. package/dist/cache/{in-memory-cache.store.js → stores/in-memory-cache.store.js} +1 -1
  24. package/dist/cache/stores/in-memory-cache.store.js.map +1 -0
  25. package/dist/cache/stores/index.d.ts +3 -0
  26. package/dist/cache/stores/index.d.ts.map +1 -0
  27. package/dist/cache/stores/index.js +20 -0
  28. package/dist/cache/stores/index.js.map +1 -0
  29. package/dist/cache/stores/redis-cache.store.d.ts +8 -0
  30. package/dist/cache/stores/redis-cache.store.d.ts.map +1 -0
  31. package/dist/cache/stores/redis-cache.store.js +39 -0
  32. package/dist/cache/stores/redis-cache.store.js.map +1 -0
  33. package/dist/core/router.d.ts.map +1 -1
  34. package/dist/core/router.js +3 -3
  35. package/dist/core/router.js.map +1 -1
  36. package/dist/events/bootstrap.d.ts +13 -1
  37. package/dist/events/bootstrap.d.ts.map +1 -1
  38. package/dist/events/bootstrap.js +30 -2
  39. package/dist/events/bootstrap.js.map +1 -1
  40. package/dist/events/buffered-event-bus.service.d.ts +135 -0
  41. package/dist/events/buffered-event-bus.service.d.ts.map +1 -0
  42. package/dist/events/buffered-event-bus.service.js +420 -0
  43. package/dist/events/buffered-event-bus.service.js.map +1 -0
  44. package/dist/events/config/buffered-event-config.d.ts +153 -0
  45. package/dist/events/config/buffered-event-config.d.ts.map +1 -0
  46. package/dist/events/config/buffered-event-config.js +181 -0
  47. package/dist/events/config/buffered-event-config.js.map +1 -0
  48. package/dist/events/index.d.ts +3 -0
  49. package/dist/events/index.d.ts.map +1 -1
  50. package/dist/events/index.js +3 -0
  51. package/dist/events/index.js.map +1 -1
  52. package/dist/events/metrics/event-metrics.d.ts +175 -0
  53. package/dist/events/metrics/event-metrics.d.ts.map +1 -0
  54. package/dist/events/metrics/event-metrics.js +235 -0
  55. package/dist/events/metrics/event-metrics.js.map +1 -0
  56. package/dist/events/monitoring/health-monitor.d.ts +142 -0
  57. package/dist/events/monitoring/health-monitor.d.ts.map +1 -0
  58. package/dist/events/monitoring/health-monitor.js +492 -0
  59. package/dist/events/monitoring/health-monitor.js.map +1 -0
  60. package/dist/events/retry/retry-handler.d.ts +112 -0
  61. package/dist/events/retry/retry-handler.d.ts.map +1 -0
  62. package/dist/events/retry/retry-handler.js +218 -0
  63. package/dist/events/retry/retry-handler.js.map +1 -0
  64. package/dist/events/shared-buffer.d.ts +92 -0
  65. package/dist/events/shared-buffer.d.ts.map +1 -0
  66. package/dist/events/shared-buffer.js +179 -0
  67. package/dist/events/shared-buffer.js.map +1 -0
  68. package/dist/events/worker/event-processor.worker.d.ts +75 -0
  69. package/dist/events/worker/event-processor.worker.d.ts.map +1 -0
  70. package/dist/events/worker/event-processor.worker.js +293 -0
  71. package/dist/events/worker/event-processor.worker.js.map +1 -0
  72. package/dist/events/worker/worker-manager.d.ts +132 -0
  73. package/dist/events/worker/worker-manager.d.ts.map +1 -0
  74. package/dist/events/worker/worker-manager.js +436 -0
  75. package/dist/events/worker/worker-manager.js.map +1 -0
  76. package/dist/examples/auth/auth.middleware.d.ts +0 -26
  77. package/dist/examples/auth/auth.middleware.d.ts.map +1 -1
  78. package/dist/examples/auth/auth.middleware.js +0 -185
  79. package/dist/examples/auth/auth.middleware.js.map +1 -1
  80. package/dist/examples/controllers/auth.controller.d.ts +0 -63
  81. package/dist/examples/controllers/auth.controller.d.ts.map +1 -1
  82. package/dist/examples/controllers/auth.controller.js +247 -282
  83. package/dist/examples/controllers/auth.controller.js.map +1 -1
  84. package/dist/examples/events/buffered-event-example.d.ts +71 -0
  85. package/dist/examples/events/buffered-event-example.d.ts.map +1 -0
  86. package/dist/examples/events/buffered-event-example.js +182 -0
  87. package/dist/examples/events/buffered-event-example.js.map +1 -0
  88. package/dist/examples/events/integration-test.d.ts +10 -0
  89. package/dist/examples/events/integration-test.d.ts.map +1 -0
  90. package/dist/examples/events/integration-test.js +147 -0
  91. package/dist/examples/events/integration-test.js.map +1 -0
  92. package/dist/examples/index.d.ts +1 -0
  93. package/dist/examples/index.d.ts.map +1 -1
  94. package/dist/examples/index.js +11 -7
  95. package/dist/examples/index.js.map +1 -1
  96. package/dist/examples/todos/schema.d.ts +4 -4
  97. package/package.json +2 -1
  98. package/dist/cache/in-memory-cache.store.d.ts.map +0 -1
  99. package/dist/cache/in-memory-cache.store.js.map +0 -1
  100. package/dist/examples/authorization-examples.d.ts +0 -67
  101. package/dist/examples/authorization-examples.d.ts.map +0 -1
  102. package/dist/examples/authorization-examples.js +0 -202
  103. package/dist/examples/authorization-examples.js.map +0 -1
  104. package/dist/examples/controllers/todo-updated.controller.d.ts +0 -103
  105. package/dist/examples/controllers/todo-updated.controller.d.ts.map +0 -1
  106. package/dist/examples/controllers/todo-updated.controller.js +0 -328
  107. package/dist/examples/controllers/todo-updated.controller.js.map +0 -1
  108. package/dist/examples/controllers/todo-with-jwt-auth.controller.d.ts +0 -114
  109. package/dist/examples/controllers/todo-with-jwt-auth.controller.d.ts.map +0 -1
  110. package/dist/examples/controllers/todo-with-jwt-auth.controller.js +0 -329
  111. package/dist/examples/controllers/todo-with-jwt-auth.controller.js.map +0 -1
  112. package/dist/examples/jwt-auth-example.d.ts +0 -47
  113. package/dist/examples/jwt-auth-example.d.ts.map +0 -1
  114. package/dist/examples/jwt-auth-example.js +0 -316
  115. package/dist/examples/jwt-auth-example.js.map +0 -1
  116. package/dist/examples/services/user.service.d.ts +0 -99
  117. package/dist/examples/services/user.service.d.ts.map +0 -1
  118. package/dist/examples/services/user.service.js +0 -281
  119. package/dist/examples/services/user.service.js.map +0 -1
  120. package/dist/examples/test-auth-flow.d.ts +0 -56
  121. package/dist/examples/test-auth-flow.d.ts.map +0 -1
  122. package/dist/examples/test-auth-flow.js +0 -449
  123. package/dist/examples/test-auth-flow.js.map +0 -1
@@ -1,328 +0,0 @@
1
- "use strict";
2
- var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
- else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
- return c > 3 && r && Object.defineProperty(target, key, r), r;
7
- };
8
- var __metadata = (this && this.__metadata) || function (k, v) {
9
- if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
10
- };
11
- var __param = (this && this.__param) || function (paramIndex, decorator) {
12
- return function (target, key) { decorator(target, key, paramIndex); }
13
- };
14
- Object.defineProperty(exports, "__esModule", { value: true });
15
- exports.TodoController = void 0;
16
- exports.registerTodoRoutes = registerTodoRoutes;
17
- const zod_1 = require("zod");
18
- const decorators_1 = require("../../cache/decorators");
19
- const decorators_2 = require("../../core/decorators");
20
- const di_container_1 = require("../../core/di-container");
21
- const request_context_service_1 = require("../../core/request-context.service");
22
- const decorators_3 = require("../../logging/core/decorators");
23
- const tracing_service_1 = require("../../logging/core/tracing.service");
24
- const auth_middleware_1 = require("../../middleware/auth.middleware");
25
- // Remove the old authorize import
26
- // import { authorize } from '../../middleware/authorization.middleware'
27
- const todo_service_1 = require("../services/todo.service");
28
- const auth_1 = require("../../auth");
29
- const AuthMiddleware_1 = require("../../auth/middleware/AuthMiddleware");
30
- const createTodoSchema = {
31
- body: zod_1.z
32
- .object({
33
- text: zod_1.z.string().min(1, 'Text cannot be empty'),
34
- })
35
- .required(),
36
- };
37
- const todoSchema = zod_1.z
38
- .object({
39
- text: zod_1.z.string().min(2, 'Text cannot be empty'),
40
- })
41
- .required();
42
- const getTodoByIdSchema = {
43
- params: zod_1.z.object({
44
- id: zod_1.z.string().regex(/^\d+$/, 'ID must be a numeric string'),
45
- }),
46
- };
47
- /**
48
- * Updated TodoController using JWT Middleware Authorization
49
- *
50
- * This shows how to replace authorize(['manager']) with JWT middleware methods
51
- */
52
- let TodoController = class TodoController {
53
- constructor(todoService) {
54
- this.todoService = todoService;
55
- }
56
- getAllTodos() {
57
- const requestContext = di_container_1.container.resolve(request_context_service_1.RequestContextService);
58
- const requestId = requestContext.get('requestId');
59
- this.logger.info(`Request ID: ${requestId}`);
60
- this.logger.info('Hello from get all todos');
61
- return this.todoService.getAllTodos();
62
- }
63
- getTodoById(id) {
64
- this.logger.info(`Hello from get todo by id: ${id}`);
65
- return this.todoService.getTodoById(id);
66
- }
67
- /**
68
- * OPTION 1: Direct replacement using requireRoles
69
- * This is the most direct replacement for authorize(['manager'])
70
- */
71
- // Replace: @UseMiddleware(authorize(['manager']))
72
- // With: @UseMiddleware(this.jwtAuthMiddleware.requireRoles(['manager']))
73
- async createTodoOption1(body) {
74
- this.logger.info('Creating todo with requireRoles', body);
75
- const data = await this.todoService.createTodo(body.text);
76
- return data;
77
- }
78
- /**
79
- * OPTION 2: Using requireAuth with explicit strategy and roles
80
- * More explicit about authentication strategy
81
- */
82
- // @UseMiddleware(this.jwtAuthMiddleware.requireAuth(['jwt'], ['manager']))
83
- async createTodoOption2(body) {
84
- this.logger.info('Creating todo with requireAuth', body);
85
- const data = await this.todoService.createTodo(body.text);
86
- return data;
87
- }
88
- /**
89
- * OPTION 3: Permission-based authorization
90
- * More granular control using permissions instead of roles
91
- */
92
- // @UseMiddleware(this.jwtAuthMiddleware.requirePermissions(['todo:create']))
93
- async createTodoOption3(body) {
94
- this.logger.info('Creating todo with requirePermissions', body);
95
- const data = await this.todoService.createTodo(body.text);
96
- return data;
97
- }
98
- /**
99
- * OPTION 4: Combined role and permission check
100
- * Most secure - requires both role AND permission
101
- */
102
- // @UseMiddleware(this.jwtAuthMiddleware.requireAuth(['jwt'], ['manager'], ['todo:create']))
103
- async createTodoOption4(body) {
104
- this.logger.info('Creating todo with combined auth', body);
105
- const data = await this.todoService.createTodo(body.text);
106
- return data;
107
- }
108
- /**
109
- * YOUR ORIGINAL METHOD - Updated to use JWT middleware
110
- * This is how you would update your existing createTodo method
111
- */
112
- // OLD: @UseMiddleware(authorize(['manager']))
113
- // NEW: Choose one of these options:
114
- // @UseMiddleware(this.jwtAuthMiddleware.requireRoles(['manager']))
115
- // @UseMiddleware(this.jwtAuthMiddleware.requireAuth(['jwt'], ['manager']))
116
- // @UseMiddleware(this.jwtAuthMiddleware.requirePermissions(['todo:create']))
117
- async createTodo(body) {
118
- // const span = this.tracingService.spanStart('create.todo.controller', {
119
- // name: 'create todo controller',
120
- // hello: 'world',
121
- // company: 'Jiocinema',
122
- // })
123
- // this.tracingService.addTags({
124
- // text: body.text,
125
- // })
126
- this.logger.info('Hello from create todo', body);
127
- const data = await this.todoService.createTodo(body.text);
128
- // this.tracingService.spanEnd(span, 'ok')
129
- return data;
130
- }
131
- };
132
- exports.TodoController = TodoController;
133
- __decorate([
134
- (0, decorators_2.Autowired)(tracing_service_1.TracingService),
135
- __metadata("design:type", tracing_service_1.TracingService)
136
- ], TodoController.prototype, "tracingService", void 0);
137
- __decorate([
138
- (0, decorators_2.Autowired)('AuthManager'),
139
- __metadata("design:type", auth_1.AuthManager
140
- // Add JWT middleware injection
141
- )
142
- ], TodoController.prototype, "authManager", void 0);
143
- __decorate([
144
- (0, decorators_2.Autowired)('JwtAuthMiddleware'),
145
- __metadata("design:type", AuthMiddleware_1.AuthMiddleware)
146
- ], TodoController.prototype, "jwtAuthMiddleware", void 0);
147
- __decorate([
148
- (0, decorators_2.Get)('/'),
149
- __metadata("design:type", Function),
150
- __metadata("design:paramtypes", []),
151
- __metadata("design:returntype", void 0)
152
- ], TodoController.prototype, "getAllTodos", null);
153
- __decorate([
154
- (0, decorators_2.Get)('/:id'),
155
- (0, decorators_1.Cacheable)({ key: 'todo', ttl: 60 }),
156
- __param(0, (0, decorators_2.Param)('id')),
157
- __metadata("design:type", Function),
158
- __metadata("design:paramtypes", [String]),
159
- __metadata("design:returntype", void 0)
160
- ], TodoController.prototype, "getTodoById", null);
161
- __decorate([
162
- (0, decorators_2.Post)('/option1'),
163
- (0, decorators_3.Audit)({
164
- action: 'create',
165
- resource: 'todo',
166
- }),
167
- (0, decorators_2.Schema)({
168
- body: todoSchema,
169
- responses: {
170
- 201: zod_1.z.object({
171
- id: zod_1.z.string(),
172
- text: zod_1.z.string(),
173
- completed: zod_1.z.boolean(),
174
- }),
175
- },
176
- })
177
- // Replace: @UseMiddleware(authorize(['manager']))
178
- // With: @UseMiddleware(this.jwtAuthMiddleware.requireRoles(['manager']))
179
- ,
180
- __param(0, (0, decorators_2.Body)()),
181
- __metadata("design:type", Function),
182
- __metadata("design:paramtypes", [void 0]),
183
- __metadata("design:returntype", Promise)
184
- ], TodoController.prototype, "createTodoOption1", null);
185
- __decorate([
186
- (0, decorators_2.Post)('/option2'),
187
- (0, decorators_3.Audit)({
188
- action: 'create',
189
- resource: 'todo',
190
- }),
191
- (0, decorators_2.Schema)({
192
- body: todoSchema,
193
- responses: {
194
- 201: zod_1.z.object({
195
- id: zod_1.z.string(),
196
- text: zod_1.z.string(),
197
- completed: zod_1.z.boolean(),
198
- }),
199
- },
200
- })
201
- // @UseMiddleware(this.jwtAuthMiddleware.requireAuth(['jwt'], ['manager']))
202
- ,
203
- __param(0, (0, decorators_2.Body)()),
204
- __metadata("design:type", Function),
205
- __metadata("design:paramtypes", [void 0]),
206
- __metadata("design:returntype", Promise)
207
- ], TodoController.prototype, "createTodoOption2", null);
208
- __decorate([
209
- (0, decorators_2.Post)('/option3'),
210
- (0, decorators_3.Audit)({
211
- action: 'create',
212
- resource: 'todo',
213
- }),
214
- (0, decorators_2.Schema)({
215
- body: todoSchema,
216
- responses: {
217
- 201: zod_1.z.object({
218
- id: zod_1.z.string(),
219
- text: zod_1.z.string(),
220
- completed: zod_1.z.boolean(),
221
- }),
222
- },
223
- })
224
- // @UseMiddleware(this.jwtAuthMiddleware.requirePermissions(['todo:create']))
225
- ,
226
- __param(0, (0, decorators_2.Body)()),
227
- __metadata("design:type", Function),
228
- __metadata("design:paramtypes", [void 0]),
229
- __metadata("design:returntype", Promise)
230
- ], TodoController.prototype, "createTodoOption3", null);
231
- __decorate([
232
- (0, decorators_2.Post)('/option4'),
233
- (0, decorators_3.Audit)({
234
- action: 'create',
235
- resource: 'todo',
236
- }),
237
- (0, decorators_2.Schema)({
238
- body: todoSchema,
239
- responses: {
240
- 201: zod_1.z.object({
241
- id: zod_1.z.string(),
242
- text: zod_1.z.string(),
243
- completed: zod_1.z.boolean(),
244
- }),
245
- },
246
- })
247
- // @UseMiddleware(this.jwtAuthMiddleware.requireAuth(['jwt'], ['manager'], ['todo:create']))
248
- ,
249
- __param(0, (0, decorators_2.Body)()),
250
- __metadata("design:type", Function),
251
- __metadata("design:paramtypes", [void 0]),
252
- __metadata("design:returntype", Promise)
253
- ], TodoController.prototype, "createTodoOption4", null);
254
- __decorate([
255
- (0, decorators_2.Post)('/'),
256
- (0, decorators_3.Audit)({
257
- action: 'create',
258
- resource: 'todo',
259
- }),
260
- (0, decorators_2.Schema)({
261
- body: todoSchema,
262
- responses: {
263
- 201: zod_1.z.object({
264
- id: zod_1.z.string(),
265
- text: zod_1.z.string(),
266
- completed: zod_1.z.boolean(),
267
- }),
268
- },
269
- })
270
- // OLD: @UseMiddleware(authorize(['manager']))
271
- // NEW: Choose one of these options:
272
- // @UseMiddleware(this.jwtAuthMiddleware.requireRoles(['manager']))
273
- // @UseMiddleware(this.jwtAuthMiddleware.requireAuth(['jwt'], ['manager']))
274
- // @UseMiddleware(this.jwtAuthMiddleware.requirePermissions(['todo:create']))
275
- ,
276
- __param(0, (0, decorators_2.Body)()),
277
- __metadata("design:type", Function),
278
- __metadata("design:paramtypes", [void 0]),
279
- __metadata("design:returntype", Promise)
280
- ], TodoController.prototype, "createTodo", null);
281
- exports.TodoController = TodoController = __decorate([
282
- (0, decorators_3.Loggable)(),
283
- (0, decorators_2.Controller)('/todos'),
284
- (0, decorators_2.UseMiddleware)((0, auth_middleware_1.authenticate)(process.env.JWT_SECRET || 'your-secret-key')),
285
- __metadata("design:paramtypes", [todo_service_1.TodoService])
286
- ], TodoController);
287
- /**
288
- * IMPORTANT: To make this work, you need to:
289
- *
290
- * 1. Register JWT middleware in your DI container (in src/examples/index.ts):
291
- *
292
- * container.register('JwtAuthMiddleware', {
293
- * useFactory: () => jwtAuthMiddleware
294
- * })
295
- *
296
- * 2. The middleware methods are commented out because decorators can't access
297
- * instance properties. You have two solutions:
298
- *
299
- * Solution A: Use manual route registration (see registerTodoRoutes function below)
300
- * Solution B: Create a factory function that returns the middleware
301
- *
302
- * 3. Update your user model to include roles/permissions that match what
303
- * you're checking for (e.g., 'manager' role, 'todo:create' permission)
304
- */
305
- /**
306
- * Solution A: Manual Route Registration
307
- * Use this approach if decorators don't work with instance methods
308
- */
309
- function registerTodoRoutes(app, todoController, jwtAuthMiddleware) {
310
- // Replace authorize(['manager']) with JWT middleware
311
- app.post('/todos', {
312
- preHandler: jwtAuthMiddleware.requireRoles(['manager'])
313
- }, async (request, reply) => {
314
- return await todoController.createTodo(request.body);
315
- });
316
- // Other authorization examples
317
- app.post('/todos/permission-based', {
318
- preHandler: jwtAuthMiddleware.requirePermissions(['todo:create'])
319
- }, async (request, reply) => {
320
- return await todoController.createTodo(request.body);
321
- });
322
- app.post('/todos/combined', {
323
- preHandler: jwtAuthMiddleware.requireAuth(['jwt'], ['manager'], ['todo:create'])
324
- }, async (request, reply) => {
325
- return await todoController.createTodo(request.body);
326
- });
327
- }
328
- //# sourceMappingURL=todo-updated.controller.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"todo-updated.controller.js","sourceRoot":"","sources":["../../../src/examples/controllers/todo-updated.controller.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AA2PA,gDAwBC;AAnRD,6BAAuB;AACvB,uDAAkD;AAClD,sDAS8B;AAC9B,0DAAmD;AACnD,gFAA0E;AAC1E,8DAA+D;AAE/D,wEAAmE;AACnE,sEAA+D;AAC/D,kCAAkC;AAClC,wEAAwE;AACxE,2DAAsD;AACtD,qCAAwC;AACxC,yEAAqE;AAErE,MAAM,gBAAgB,GAAG;IACvB,IAAI,EAAE,OAAC;SACJ,MAAM,CAAC;QACN,IAAI,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,EAAE,sBAAsB,CAAC;KAChD,CAAC;SACD,QAAQ,EAAE;CACd,CAAA;AAED,MAAM,UAAU,GAAG,OAAC;KACjB,MAAM,CAAC;IACN,IAAI,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,EAAE,sBAAsB,CAAC;CAChD,CAAC;KACD,QAAQ,EAAE,CAAA;AAEb,MAAM,iBAAiB,GAAG;IACxB,MAAM,EAAE,OAAC,CAAC,MAAM,CAAC;QACf,EAAE,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,KAAK,CAAC,OAAO,EAAE,6BAA6B,CAAC;KAC7D,CAAC;CAC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AK,EAAE,OAAY,EAAE,KAAU,EAAE,EAAE;QACpC,OAAO,MAAM,cAAc,CAAC,UAAU,CAAC,OAAO,CAAC,IAAI,CAAC,CAAA;IACtD,CAAC,CAAC,CAAA;AACJ,CAAC"}
@@ -1,114 +0,0 @@
1
- import { z } from 'zod';
2
- import { TodoService } from '../services/todo.service';
3
- import { AuthMiddleware } from '../../auth/middleware/AuthMiddleware';
4
- declare const todoSchema: z.ZodObject<{
5
- text: z.ZodString;
6
- }, "strip", z.ZodTypeAny, {
7
- text: string;
8
- }, {
9
- text: string;
10
- }>;
11
- /**
12
- * Enhanced TodoController using JWT Middleware Authorization
13
- *
14
- * This controller demonstrates different authorization patterns
15
- * using the built-in JWT middleware methods instead of the
16
- * separate authorize() middleware.
17
- */
18
- export declare class TodoWithJwtAuthController {
19
- private readonly todoService;
20
- constructor(todoService: TodoService);
21
- private tracingService;
22
- private authManager;
23
- private logger;
24
- private jwtAuthMiddleware;
25
- setJwtMiddleware(middleware: AuthMiddleware): void;
26
- /**
27
- * Public endpoint - no authentication required
28
- */
29
- getPublicTodos(): Promise<{
30
- id: string;
31
- text: string;
32
- completed: boolean;
33
- }[]>;
34
- /**
35
- * Optional authentication - user info available if authenticated
36
- */
37
- getTodosWithOptionalAuth(): Promise<{
38
- id: string;
39
- text: string;
40
- completed: boolean;
41
- }[]>;
42
- /**
43
- * Basic authentication required - any authenticated user
44
- */
45
- getAuthenticatedTodos(): Promise<{
46
- id: string;
47
- text: string;
48
- completed: boolean;
49
- }[]>;
50
- /**
51
- * Role-based authorization - equivalent to authorize(['manager'])
52
- */
53
- createTodoRoleBased(body: z.infer<typeof todoSchema>): Promise<{
54
- id: string;
55
- text: string;
56
- completed: boolean;
57
- }>;
58
- /**
59
- * Permission-based authorization - more granular control
60
- */
61
- createTodoPermissionBased(body: z.infer<typeof todoSchema>): Promise<{
62
- id: string;
63
- text: string;
64
- completed: boolean;
65
- }>;
66
- /**
67
- * Combined role and permission authorization
68
- */
69
- createTodoCombined(body: z.infer<typeof todoSchema>): Promise<{
70
- id: string;
71
- text: string;
72
- completed: boolean;
73
- }>;
74
- /**
75
- * Strategy-specific authorization - JWT only with admin role
76
- */
77
- adminOnlyEndpoint(body: any): Promise<{
78
- message: string;
79
- data: any;
80
- }>;
81
- /**
82
- * Get todo by ID with caching and role-based auth
83
- */
84
- getTodoById(id: string): Promise<{
85
- id: string;
86
- text: string;
87
- completed: boolean;
88
- }>;
89
- /**
90
- * Update todo - requires specific permissions
91
- */
92
- updateTodo(id: string, body: z.infer<typeof todoSchema>): Promise<{
93
- updated: boolean;
94
- text: string;
95
- id: string;
96
- }>;
97
- /**
98
- * Delete todo - admin or owner only
99
- */
100
- deleteTodo(id: string): Promise<{
101
- message: string;
102
- }>;
103
- }
104
- /**
105
- * Helper function to setup the controller with JWT middleware
106
- */
107
- export declare function setupTodoWithJwtAuth(controller: TodoWithJwtAuthController, jwtAuthMiddleware: AuthMiddleware): void;
108
- /**
109
- * Example of how to register routes manually with Fastify
110
- * (Alternative to using decorators)
111
- */
112
- export declare function registerTodoJwtAuthRoutes(app: any, todoService: TodoService, jwtAuthMiddleware: AuthMiddleware): void;
113
- export {};
114
- //# sourceMappingURL=todo-with-jwt-auth.controller.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"todo-with-jwt-auth.controller.d.ts","sourceRoot":"","sources":["../../../src/examples/controllers/todo-with-jwt-auth.controller.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAevB,OAAO,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAA;AAEtD,OAAO,EAAE,cAAc,EAAE,MAAM,sCAAsC,CAAA;AAErE,QAAA,MAAM,UAAU;;;;;;EAIH,CAAA;AAQb;;;;;;GAMG;AACH,qBAEa,yBAAyB;IACxB,OAAO,CAAC,QAAQ,CAAC,WAAW;gBAAX,WAAW,EAAE,WAAW;IAGrD,OAAO,CAAC,cAAc,CAAiB;IAGvC,OAAO,CAA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