@easyweb/rabbitmq-utils 1.0.18 → 1.0.19
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +426 -426
- package/dist/events/types/auth-events.d.ts +1 -0
- package/dist/events/types/auth-events.d.ts.map +1 -1
- package/package.json +68 -68
package/README.md
CHANGED
|
@@ -1,426 +1,426 @@
|
|
|
1
|
-
# @myfoto/easyweb-common
|
|
2
|
-
|
|
3
|
-
A shared utility library for Easyweb microservices built with TypeScript. This package provides common functionality including a type-safe RabbitMQ event system (publishers, subscribers, exchanges, and routing keys).
|
|
4
|
-
|
|
5
|
-
## Installation
|
|
6
|
-
|
|
7
|
-
```bash
|
|
8
|
-
npm install @myfoto/easyweb-common
|
|
9
|
-
```
|
|
10
|
-
|
|
11
|
-
## Features
|
|
12
|
-
|
|
13
|
-
- 🚨 **Error Handling** - Custom error classes with consistent serialization
|
|
14
|
-
- ✅ **Validation** - Zod-based request/response validation with common patterns
|
|
15
|
-
- 🗃️ **Database Utilities** - Prisma helpers, transactions, and health checks
|
|
16
|
-
- 🔐 **Password Management** - Hashing, validation, and secure token generation
|
|
17
|
-
- 📄 **Response Formatting** - Standardized API responses with pagination
|
|
18
|
-
- 📊 **Pagination** - Cursor and offset-based pagination utilities
|
|
19
|
-
- 📝 **Logging** - Structured logging with performance monitoring
|
|
20
|
-
- 🛡️ **Middleware** - Rate limiting, error handling, and more
|
|
21
|
-
- 🐰 **RabbitMQ Event System** - Type-safe event-driven architecture with publishers and subscribers
|
|
22
|
-
|
|
23
|
-
## Quick Start
|
|
24
|
-
|
|
25
|
-
```typescript
|
|
26
|
-
import {
|
|
27
|
-
// Error classes
|
|
28
|
-
BadRequestError,
|
|
29
|
-
NotFoundError,
|
|
30
|
-
ValidationPatterns,
|
|
31
|
-
|
|
32
|
-
// Utilities
|
|
33
|
-
PasswordService,
|
|
34
|
-
ResponseFormatter,
|
|
35
|
-
PaginationService,
|
|
36
|
-
Logger,
|
|
37
|
-
DatabaseService,
|
|
38
|
-
|
|
39
|
-
// Middleware
|
|
40
|
-
errorHandler,
|
|
41
|
-
validateRequest,
|
|
42
|
-
responseFormatter,
|
|
43
|
-
} from '@glow-up/common-shared';
|
|
44
|
-
|
|
45
|
-
// Use in your Express app
|
|
46
|
-
import express from 'express';
|
|
47
|
-
|
|
48
|
-
const app = express();
|
|
49
|
-
|
|
50
|
-
// Add response formatter middleware
|
|
51
|
-
app.use(responseFormatter);
|
|
52
|
-
|
|
53
|
-
// Add error handler (should be last)
|
|
54
|
-
app.use(errorHandler);
|
|
55
|
-
```
|
|
56
|
-
|
|
57
|
-
## Error Handling
|
|
58
|
-
|
|
59
|
-
### Custom Error Classes
|
|
60
|
-
|
|
61
|
-
```typescript
|
|
62
|
-
import {
|
|
63
|
-
BadRequestError,
|
|
64
|
-
NotFoundError,
|
|
65
|
-
ValidationError,
|
|
66
|
-
} from '@glow-up/common-shared';
|
|
67
|
-
|
|
68
|
-
// Throw errors that will be automatically handled
|
|
69
|
-
throw new BadRequestError('Invalid input data');
|
|
70
|
-
throw new NotFoundError('User not found');
|
|
71
|
-
throw new ValidationError([
|
|
72
|
-
{ field: 'email', message: 'Invalid email format' },
|
|
73
|
-
]);
|
|
74
|
-
```
|
|
75
|
-
|
|
76
|
-
### Error Handler Middleware
|
|
77
|
-
|
|
78
|
-
```typescript
|
|
79
|
-
import { errorHandler } from '@glow-up/common-shared';
|
|
80
|
-
|
|
81
|
-
// Add as the last middleware
|
|
82
|
-
app.use(errorHandler);
|
|
83
|
-
```
|
|
84
|
-
|
|
85
|
-
## Validation
|
|
86
|
-
|
|
87
|
-
### Request Validation with Zod
|
|
88
|
-
|
|
89
|
-
```typescript
|
|
90
|
-
import { validateRequest, ValidationPatterns } from '@glow-up/common-shared';
|
|
91
|
-
import { z } from 'zod';
|
|
92
|
-
|
|
93
|
-
// Use predefined patterns
|
|
94
|
-
const loginSchema = {
|
|
95
|
-
body: z.object({
|
|
96
|
-
email: ValidationPatterns.email(),
|
|
97
|
-
password: z.string().min(1),
|
|
98
|
-
}),
|
|
99
|
-
};
|
|
100
|
-
|
|
101
|
-
app.post('/login', validateRequest(loginSchema), (req, res) => {
|
|
102
|
-
// req.body is now validated and typed
|
|
103
|
-
const { email, password } = req.body;
|
|
104
|
-
res.success({ message: 'Login successful' });
|
|
105
|
-
});
|
|
106
|
-
|
|
107
|
-
// Common validation middleware
|
|
108
|
-
import { ValidationMiddleware } from '@glow-up/common-shared';
|
|
109
|
-
|
|
110
|
-
app.post(
|
|
111
|
-
'/register',
|
|
112
|
-
ValidationMiddleware.validateRegistration(),
|
|
113
|
-
(req, res) => {
|
|
114
|
-
// Handles email, password, name validation
|
|
115
|
-
},
|
|
116
|
-
);
|
|
117
|
-
```
|
|
118
|
-
|
|
119
|
-
## Response Formatting
|
|
120
|
-
|
|
121
|
-
### Standardized API Responses
|
|
122
|
-
|
|
123
|
-
```typescript
|
|
124
|
-
import { ResponseFormatter } from '@glow-up/common-shared';
|
|
125
|
-
|
|
126
|
-
// Success response
|
|
127
|
-
ResponseFormatter.success(res, { user: userData }, 'User created');
|
|
128
|
-
// { success: true, message: 'User created', data: { user: userData }, metadata: { timestamp: ... } }
|
|
129
|
-
|
|
130
|
-
// Error response
|
|
131
|
-
ResponseFormatter.error(res, 'Invalid credentials', 'Login failed', 401);
|
|
132
|
-
|
|
133
|
-
// Paginated response
|
|
134
|
-
ResponseFormatter.paginated(res, users, { page: 1, limit: 10, total: 100 });
|
|
135
|
-
|
|
136
|
-
// Using middleware (adds methods to res object)
|
|
137
|
-
app.use(responseFormatter);
|
|
138
|
-
|
|
139
|
-
app.get('/users', (req, res) => {
|
|
140
|
-
res.success(users, 'Users retrieved');
|
|
141
|
-
res.paginated(users, paginationInfo);
|
|
142
|
-
res.notFound('User not found');
|
|
143
|
-
});
|
|
144
|
-
```
|
|
145
|
-
|
|
146
|
-
## Pagination
|
|
147
|
-
|
|
148
|
-
```typescript
|
|
149
|
-
import { PaginationService, parseSort } from '@glow-up/common-shared';
|
|
150
|
-
|
|
151
|
-
// Parse pagination params
|
|
152
|
-
const pagination = PaginationService.parsePagination({
|
|
153
|
-
page: req.query.page,
|
|
154
|
-
limit: req.query.limit,
|
|
155
|
-
});
|
|
156
|
-
|
|
157
|
-
// For Prisma
|
|
158
|
-
const prismaOptions = PaginationService.toPrisma(pagination, sort);
|
|
159
|
-
const users = await prisma.user.findMany(prismaOptions);
|
|
160
|
-
|
|
161
|
-
// Generate metadata
|
|
162
|
-
const metadata = PaginationService.generateMetadata(
|
|
163
|
-
pagination.page,
|
|
164
|
-
pagination.limit,
|
|
165
|
-
totalUsers,
|
|
166
|
-
);
|
|
167
|
-
|
|
168
|
-
res.paginated(users, metadata);
|
|
169
|
-
```
|
|
170
|
-
|
|
171
|
-
## Database Utilities
|
|
172
|
-
|
|
173
|
-
```typescript
|
|
174
|
-
import { DatabaseService } from '@glow-up/common-shared';
|
|
175
|
-
import { PrismaClient } from '@prisma/client';
|
|
176
|
-
|
|
177
|
-
const prisma = new PrismaClient();
|
|
178
|
-
const dbService = new DatabaseService(prisma);
|
|
179
|
-
|
|
180
|
-
// Health check
|
|
181
|
-
const health = await dbService.healthCheck();
|
|
182
|
-
|
|
183
|
-
// Transactions
|
|
184
|
-
const result = await dbService.withTransaction(async tx => {
|
|
185
|
-
const user = await tx.user.create({ data: userData });
|
|
186
|
-
const profile = await tx.profile.create({
|
|
187
|
-
data: { userId: user.id, ...profileData },
|
|
188
|
-
});
|
|
189
|
-
return { user, profile };
|
|
190
|
-
});
|
|
191
|
-
|
|
192
|
-
// Batch operations
|
|
193
|
-
await dbService.batchCreate('user', userDataArray, 50);
|
|
194
|
-
|
|
195
|
-
// Soft delete
|
|
196
|
-
await dbService.softDelete('user', { id: userId });
|
|
197
|
-
```
|
|
198
|
-
|
|
199
|
-
## Password Management
|
|
200
|
-
|
|
201
|
-
```typescript
|
|
202
|
-
import { PasswordService } from '@glow-up/common-shared';
|
|
203
|
-
|
|
204
|
-
// Hash password
|
|
205
|
-
const hashedPassword = await PasswordService.hashPassword('mypassword');
|
|
206
|
-
|
|
207
|
-
// Compare password
|
|
208
|
-
const isValid = await PasswordService.comparePassword(
|
|
209
|
-
'mypassword',
|
|
210
|
-
hashedPassword,
|
|
211
|
-
);
|
|
212
|
-
|
|
213
|
-
// Generate secure tokens
|
|
214
|
-
const token = PasswordService.generateSecureToken(32);
|
|
215
|
-
const resetToken = PasswordService.generatePasswordResetToken();
|
|
216
|
-
|
|
217
|
-
// Check password strength
|
|
218
|
-
const strength = PasswordService.checkPasswordStrength('mypassword');
|
|
219
|
-
console.log(strength.isStrong); // boolean
|
|
220
|
-
console.log(strength.feedback); // array of suggestions
|
|
221
|
-
```
|
|
222
|
-
|
|
223
|
-
## RabbitMQ Event System
|
|
224
|
-
|
|
225
|
-
### Quick Start
|
|
226
|
-
|
|
227
|
-
```typescript
|
|
228
|
-
import {
|
|
229
|
-
Publisher,
|
|
230
|
-
Subscriber,
|
|
231
|
-
Exchanges,
|
|
232
|
-
RoutingKeys,
|
|
233
|
-
UserProfileCreatedEvent,
|
|
234
|
-
} from '@myfoto/common-shared';
|
|
235
|
-
import { Channel } from 'amqplib';
|
|
236
|
-
|
|
237
|
-
// Create a publisher
|
|
238
|
-
export class UserProfileCreatedPublisher extends Publisher<UserProfileCreatedEvent> {
|
|
239
|
-
exchange = Exchanges.UserProfile;
|
|
240
|
-
routingKey = RoutingKeys.UserProfileCreated;
|
|
241
|
-
}
|
|
242
|
-
|
|
243
|
-
// Publish an event
|
|
244
|
-
const publisher = new UserProfileCreatedPublisher(channel);
|
|
245
|
-
await publisher.publish({
|
|
246
|
-
userId: '123',
|
|
247
|
-
name: 'John Doe',
|
|
248
|
-
email: 'john@example.com',
|
|
249
|
-
});
|
|
250
|
-
|
|
251
|
-
// Create a subscriber
|
|
252
|
-
export class UserProfileCreatedSubscriber extends Subscriber<UserProfileCreatedEvent> {
|
|
253
|
-
exchange = Exchanges.UserProfile;
|
|
254
|
-
routingKey = RoutingKeys.UserProfileCreated;
|
|
255
|
-
|
|
256
|
-
async onMessage(
|
|
257
|
-
data: UserProfileCreatedEvent['data'],
|
|
258
|
-
msg: ConsumeMessage,
|
|
259
|
-
): Promise<void> {
|
|
260
|
-
console.log('User created:', data);
|
|
261
|
-
// Your business logic here
|
|
262
|
-
}
|
|
263
|
-
}
|
|
264
|
-
|
|
265
|
-
// Subscribe to events
|
|
266
|
-
const subscriber = new UserProfileCreatedSubscriber(channel);
|
|
267
|
-
await subscriber.subscribe();
|
|
268
|
-
```
|
|
269
|
-
|
|
270
|
-
### Features
|
|
271
|
-
|
|
272
|
-
- ✅ **Type-safe events** - Full TypeScript support with autocomplete
|
|
273
|
-
- ✅ **Centralized definitions** - All events defined in one package
|
|
274
|
-
- ✅ **Consistent naming** - Clear routing key conventions
|
|
275
|
-
- ✅ **Durable queues** - Messages persist across restarts
|
|
276
|
-
- ✅ **Error handling** - Automatic message requeuing on failures
|
|
277
|
-
- ✅ **Documentation** - Comprehensive guides and examples
|
|
278
|
-
|
|
279
|
-
### Available Events
|
|
280
|
-
|
|
281
|
-
**User Profile**: `UserProfileCreatedEvent`, `UserProfileUpdatedEvent`, `UserProfileDeletedEvent`
|
|
282
|
-
|
|
283
|
-
**Product**: `ProductCreatedEvent`, `ProductUpdatedEvent`, `ProductDeletedEvent`, `ProductStockChangedEvent`
|
|
284
|
-
|
|
285
|
-
**Order**: `OrderCreatedEvent`, `OrderUpdatedEvent`, `OrderCompletedEvent`, `OrderCancelledEvent`
|
|
286
|
-
|
|
287
|
-
### Routing Key Convention
|
|
288
|
-
|
|
289
|
-
Format: `<service>.<entity>.<action>`
|
|
290
|
-
|
|
291
|
-
Examples:
|
|
292
|
-
|
|
293
|
-
- `user_profile.profile.created`
|
|
294
|
-
- `product.product.updated`
|
|
295
|
-
- `order.order.completed`
|
|
296
|
-
|
|
297
|
-
### Documentation
|
|
298
|
-
|
|
299
|
-
- 📚 [Full Event System Documentation](src/events/README.md)
|
|
300
|
-
- 📋 [Event Guidelines](EVENT_GUIDELINES.md)
|
|
301
|
-
- 🚀 [Quick Reference](QUICK_REFERENCE.md)
|
|
302
|
-
- 🔄 [Migration Guide](MIGRATION.md)
|
|
303
|
-
|
|
304
|
-
## Logging
|
|
305
|
-
|
|
306
|
-
```typescript
|
|
307
|
-
import { Logger, createLogger, requestLogger } from '@myfoto/common-shared';
|
|
308
|
-
|
|
309
|
-
// Use default logger
|
|
310
|
-
import { log } from '@glow-up/common-shared';
|
|
311
|
-
|
|
312
|
-
log.info('Application started');
|
|
313
|
-
log.error('Something went wrong', error, { userId: '123' });
|
|
314
|
-
|
|
315
|
-
// Create custom logger
|
|
316
|
-
const logger = createLogger({
|
|
317
|
-
level: 'debug',
|
|
318
|
-
enableFile: true,
|
|
319
|
-
filePath: './logs/app.log',
|
|
320
|
-
});
|
|
321
|
-
|
|
322
|
-
// Add request logging middleware
|
|
323
|
-
app.use(requestLogger(logger));
|
|
324
|
-
|
|
325
|
-
// Performance logging
|
|
326
|
-
import { timeOperation } from '@glow-up/common-shared';
|
|
327
|
-
|
|
328
|
-
const result = await timeOperation(
|
|
329
|
-
'database-query',
|
|
330
|
-
() => prisma.user.findMany(),
|
|
331
|
-
logger,
|
|
332
|
-
);
|
|
333
|
-
```
|
|
334
|
-
|
|
335
|
-
## Validation Patterns
|
|
336
|
-
|
|
337
|
-
```typescript
|
|
338
|
-
import { ValidationPatterns } from '@glow-up/common-shared';
|
|
339
|
-
|
|
340
|
-
// Email with normalization
|
|
341
|
-
ValidationPatterns.email();
|
|
342
|
-
|
|
343
|
-
// Strong password requirements
|
|
344
|
-
ValidationPatterns.password();
|
|
345
|
-
|
|
346
|
-
// UUID validation
|
|
347
|
-
ValidationPatterns.uuid();
|
|
348
|
-
|
|
349
|
-
// Pagination parameters
|
|
350
|
-
ValidationPatterns.pagination();
|
|
351
|
-
|
|
352
|
-
// Phone number
|
|
353
|
-
ValidationPatterns.phoneNumber();
|
|
354
|
-
|
|
355
|
-
// Custom enum with case insensitive matching
|
|
356
|
-
ValidationPatterns.enumCaseInsensitive(['ACTIVE', 'INACTIVE']);
|
|
357
|
-
```
|
|
358
|
-
|
|
359
|
-
## TypeScript Support
|
|
360
|
-
|
|
361
|
-
This package is built with TypeScript and provides full type definitions. All utilities are properly typed for the best development experience.
|
|
362
|
-
|
|
363
|
-
```typescript
|
|
364
|
-
// Types are automatically inferred
|
|
365
|
-
import {
|
|
366
|
-
ApiResponse,
|
|
367
|
-
PaginatedResponse,
|
|
368
|
-
LogLevel,
|
|
369
|
-
} from '@glow-up/common-shared';
|
|
370
|
-
|
|
371
|
-
// Extend Express types (automatically included)
|
|
372
|
-
declare global {
|
|
373
|
-
namespace Express {
|
|
374
|
-
interface Request {
|
|
375
|
-
user?: {
|
|
376
|
-
id: string;
|
|
377
|
-
email: string;
|
|
378
|
-
roles?: string[];
|
|
379
|
-
};
|
|
380
|
-
}
|
|
381
|
-
interface Response {
|
|
382
|
-
success: (data?: any, message?: string) => void;
|
|
383
|
-
error: (errors: any, message?: string, statusCode?: number) => void;
|
|
384
|
-
// ... other response methods
|
|
385
|
-
}
|
|
386
|
-
}
|
|
387
|
-
}
|
|
388
|
-
```
|
|
389
|
-
|
|
390
|
-
## Peer Dependencies
|
|
391
|
-
|
|
392
|
-
Make sure to install peer dependencies if you're using related features:
|
|
393
|
-
|
|
394
|
-
```bash
|
|
395
|
-
# For database utilities
|
|
396
|
-
npm install @prisma/client
|
|
397
|
-
|
|
398
|
-
# For logging to files (if using file logging)
|
|
399
|
-
npm install winston
|
|
400
|
-
```
|
|
401
|
-
|
|
402
|
-
## Contributing
|
|
403
|
-
|
|
404
|
-
This package is part of the Glow Up microservices ecosystem. When adding new utilities:
|
|
405
|
-
|
|
406
|
-
1. Follow the existing patterns and TypeScript conventions
|
|
407
|
-
2. Add proper JSDoc documentation
|
|
408
|
-
3. Include unit tests
|
|
409
|
-
4. Update this README with usage examples
|
|
410
|
-
|
|
411
|
-
## License
|
|
412
|
-
|
|
413
|
-
MIT License - see LICENSE file for details.
|
|
414
|
-
|
|
415
|
-
## Changelog
|
|
416
|
-
|
|
417
|
-
### 1.0.0
|
|
418
|
-
|
|
419
|
-
- Initial release with core utilities
|
|
420
|
-
- Error handling system
|
|
421
|
-
- Validation middleware
|
|
422
|
-
- Database utilities
|
|
423
|
-
- Response formatting
|
|
424
|
-
- Pagination helpers
|
|
425
|
-
- Logging system
|
|
426
|
-
- Password management
|
|
1
|
+
# @myfoto/easyweb-common
|
|
2
|
+
|
|
3
|
+
A shared utility library for Easyweb microservices built with TypeScript. This package provides common functionality including a type-safe RabbitMQ event system (publishers, subscribers, exchanges, and routing keys).
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install @myfoto/easyweb-common
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Features
|
|
12
|
+
|
|
13
|
+
- 🚨 **Error Handling** - Custom error classes with consistent serialization
|
|
14
|
+
- ✅ **Validation** - Zod-based request/response validation with common patterns
|
|
15
|
+
- 🗃️ **Database Utilities** - Prisma helpers, transactions, and health checks
|
|
16
|
+
- 🔐 **Password Management** - Hashing, validation, and secure token generation
|
|
17
|
+
- 📄 **Response Formatting** - Standardized API responses with pagination
|
|
18
|
+
- 📊 **Pagination** - Cursor and offset-based pagination utilities
|
|
19
|
+
- 📝 **Logging** - Structured logging with performance monitoring
|
|
20
|
+
- 🛡️ **Middleware** - Rate limiting, error handling, and more
|
|
21
|
+
- 🐰 **RabbitMQ Event System** - Type-safe event-driven architecture with publishers and subscribers
|
|
22
|
+
|
|
23
|
+
## Quick Start
|
|
24
|
+
|
|
25
|
+
```typescript
|
|
26
|
+
import {
|
|
27
|
+
// Error classes
|
|
28
|
+
BadRequestError,
|
|
29
|
+
NotFoundError,
|
|
30
|
+
ValidationPatterns,
|
|
31
|
+
|
|
32
|
+
// Utilities
|
|
33
|
+
PasswordService,
|
|
34
|
+
ResponseFormatter,
|
|
35
|
+
PaginationService,
|
|
36
|
+
Logger,
|
|
37
|
+
DatabaseService,
|
|
38
|
+
|
|
39
|
+
// Middleware
|
|
40
|
+
errorHandler,
|
|
41
|
+
validateRequest,
|
|
42
|
+
responseFormatter,
|
|
43
|
+
} from '@glow-up/common-shared';
|
|
44
|
+
|
|
45
|
+
// Use in your Express app
|
|
46
|
+
import express from 'express';
|
|
47
|
+
|
|
48
|
+
const app = express();
|
|
49
|
+
|
|
50
|
+
// Add response formatter middleware
|
|
51
|
+
app.use(responseFormatter);
|
|
52
|
+
|
|
53
|
+
// Add error handler (should be last)
|
|
54
|
+
app.use(errorHandler);
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
## Error Handling
|
|
58
|
+
|
|
59
|
+
### Custom Error Classes
|
|
60
|
+
|
|
61
|
+
```typescript
|
|
62
|
+
import {
|
|
63
|
+
BadRequestError,
|
|
64
|
+
NotFoundError,
|
|
65
|
+
ValidationError,
|
|
66
|
+
} from '@glow-up/common-shared';
|
|
67
|
+
|
|
68
|
+
// Throw errors that will be automatically handled
|
|
69
|
+
throw new BadRequestError('Invalid input data');
|
|
70
|
+
throw new NotFoundError('User not found');
|
|
71
|
+
throw new ValidationError([
|
|
72
|
+
{ field: 'email', message: 'Invalid email format' },
|
|
73
|
+
]);
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
### Error Handler Middleware
|
|
77
|
+
|
|
78
|
+
```typescript
|
|
79
|
+
import { errorHandler } from '@glow-up/common-shared';
|
|
80
|
+
|
|
81
|
+
// Add as the last middleware
|
|
82
|
+
app.use(errorHandler);
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
## Validation
|
|
86
|
+
|
|
87
|
+
### Request Validation with Zod
|
|
88
|
+
|
|
89
|
+
```typescript
|
|
90
|
+
import { validateRequest, ValidationPatterns } from '@glow-up/common-shared';
|
|
91
|
+
import { z } from 'zod';
|
|
92
|
+
|
|
93
|
+
// Use predefined patterns
|
|
94
|
+
const loginSchema = {
|
|
95
|
+
body: z.object({
|
|
96
|
+
email: ValidationPatterns.email(),
|
|
97
|
+
password: z.string().min(1),
|
|
98
|
+
}),
|
|
99
|
+
};
|
|
100
|
+
|
|
101
|
+
app.post('/login', validateRequest(loginSchema), (req, res) => {
|
|
102
|
+
// req.body is now validated and typed
|
|
103
|
+
const { email, password } = req.body;
|
|
104
|
+
res.success({ message: 'Login successful' });
|
|
105
|
+
});
|
|
106
|
+
|
|
107
|
+
// Common validation middleware
|
|
108
|
+
import { ValidationMiddleware } from '@glow-up/common-shared';
|
|
109
|
+
|
|
110
|
+
app.post(
|
|
111
|
+
'/register',
|
|
112
|
+
ValidationMiddleware.validateRegistration(),
|
|
113
|
+
(req, res) => {
|
|
114
|
+
// Handles email, password, name validation
|
|
115
|
+
},
|
|
116
|
+
);
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
## Response Formatting
|
|
120
|
+
|
|
121
|
+
### Standardized API Responses
|
|
122
|
+
|
|
123
|
+
```typescript
|
|
124
|
+
import { ResponseFormatter } from '@glow-up/common-shared';
|
|
125
|
+
|
|
126
|
+
// Success response
|
|
127
|
+
ResponseFormatter.success(res, { user: userData }, 'User created');
|
|
128
|
+
// { success: true, message: 'User created', data: { user: userData }, metadata: { timestamp: ... } }
|
|
129
|
+
|
|
130
|
+
// Error response
|
|
131
|
+
ResponseFormatter.error(res, 'Invalid credentials', 'Login failed', 401);
|
|
132
|
+
|
|
133
|
+
// Paginated response
|
|
134
|
+
ResponseFormatter.paginated(res, users, { page: 1, limit: 10, total: 100 });
|
|
135
|
+
|
|
136
|
+
// Using middleware (adds methods to res object)
|
|
137
|
+
app.use(responseFormatter);
|
|
138
|
+
|
|
139
|
+
app.get('/users', (req, res) => {
|
|
140
|
+
res.success(users, 'Users retrieved');
|
|
141
|
+
res.paginated(users, paginationInfo);
|
|
142
|
+
res.notFound('User not found');
|
|
143
|
+
});
|
|
144
|
+
```
|
|
145
|
+
|
|
146
|
+
## Pagination
|
|
147
|
+
|
|
148
|
+
```typescript
|
|
149
|
+
import { PaginationService, parseSort } from '@glow-up/common-shared';
|
|
150
|
+
|
|
151
|
+
// Parse pagination params
|
|
152
|
+
const pagination = PaginationService.parsePagination({
|
|
153
|
+
page: req.query.page,
|
|
154
|
+
limit: req.query.limit,
|
|
155
|
+
});
|
|
156
|
+
|
|
157
|
+
// For Prisma
|
|
158
|
+
const prismaOptions = PaginationService.toPrisma(pagination, sort);
|
|
159
|
+
const users = await prisma.user.findMany(prismaOptions);
|
|
160
|
+
|
|
161
|
+
// Generate metadata
|
|
162
|
+
const metadata = PaginationService.generateMetadata(
|
|
163
|
+
pagination.page,
|
|
164
|
+
pagination.limit,
|
|
165
|
+
totalUsers,
|
|
166
|
+
);
|
|
167
|
+
|
|
168
|
+
res.paginated(users, metadata);
|
|
169
|
+
```
|
|
170
|
+
|
|
171
|
+
## Database Utilities
|
|
172
|
+
|
|
173
|
+
```typescript
|
|
174
|
+
import { DatabaseService } from '@glow-up/common-shared';
|
|
175
|
+
import { PrismaClient } from '@prisma/client';
|
|
176
|
+
|
|
177
|
+
const prisma = new PrismaClient();
|
|
178
|
+
const dbService = new DatabaseService(prisma);
|
|
179
|
+
|
|
180
|
+
// Health check
|
|
181
|
+
const health = await dbService.healthCheck();
|
|
182
|
+
|
|
183
|
+
// Transactions
|
|
184
|
+
const result = await dbService.withTransaction(async tx => {
|
|
185
|
+
const user = await tx.user.create({ data: userData });
|
|
186
|
+
const profile = await tx.profile.create({
|
|
187
|
+
data: { userId: user.id, ...profileData },
|
|
188
|
+
});
|
|
189
|
+
return { user, profile };
|
|
190
|
+
});
|
|
191
|
+
|
|
192
|
+
// Batch operations
|
|
193
|
+
await dbService.batchCreate('user', userDataArray, 50);
|
|
194
|
+
|
|
195
|
+
// Soft delete
|
|
196
|
+
await dbService.softDelete('user', { id: userId });
|
|
197
|
+
```
|
|
198
|
+
|
|
199
|
+
## Password Management
|
|
200
|
+
|
|
201
|
+
```typescript
|
|
202
|
+
import { PasswordService } from '@glow-up/common-shared';
|
|
203
|
+
|
|
204
|
+
// Hash password
|
|
205
|
+
const hashedPassword = await PasswordService.hashPassword('mypassword');
|
|
206
|
+
|
|
207
|
+
// Compare password
|
|
208
|
+
const isValid = await PasswordService.comparePassword(
|
|
209
|
+
'mypassword',
|
|
210
|
+
hashedPassword,
|
|
211
|
+
);
|
|
212
|
+
|
|
213
|
+
// Generate secure tokens
|
|
214
|
+
const token = PasswordService.generateSecureToken(32);
|
|
215
|
+
const resetToken = PasswordService.generatePasswordResetToken();
|
|
216
|
+
|
|
217
|
+
// Check password strength
|
|
218
|
+
const strength = PasswordService.checkPasswordStrength('mypassword');
|
|
219
|
+
console.log(strength.isStrong); // boolean
|
|
220
|
+
console.log(strength.feedback); // array of suggestions
|
|
221
|
+
```
|
|
222
|
+
|
|
223
|
+
## RabbitMQ Event System
|
|
224
|
+
|
|
225
|
+
### Quick Start
|
|
226
|
+
|
|
227
|
+
```typescript
|
|
228
|
+
import {
|
|
229
|
+
Publisher,
|
|
230
|
+
Subscriber,
|
|
231
|
+
Exchanges,
|
|
232
|
+
RoutingKeys,
|
|
233
|
+
UserProfileCreatedEvent,
|
|
234
|
+
} from '@myfoto/common-shared';
|
|
235
|
+
import { Channel } from 'amqplib';
|
|
236
|
+
|
|
237
|
+
// Create a publisher
|
|
238
|
+
export class UserProfileCreatedPublisher extends Publisher<UserProfileCreatedEvent> {
|
|
239
|
+
exchange = Exchanges.UserProfile;
|
|
240
|
+
routingKey = RoutingKeys.UserProfileCreated;
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
// Publish an event
|
|
244
|
+
const publisher = new UserProfileCreatedPublisher(channel);
|
|
245
|
+
await publisher.publish({
|
|
246
|
+
userId: '123',
|
|
247
|
+
name: 'John Doe',
|
|
248
|
+
email: 'john@example.com',
|
|
249
|
+
});
|
|
250
|
+
|
|
251
|
+
// Create a subscriber
|
|
252
|
+
export class UserProfileCreatedSubscriber extends Subscriber<UserProfileCreatedEvent> {
|
|
253
|
+
exchange = Exchanges.UserProfile;
|
|
254
|
+
routingKey = RoutingKeys.UserProfileCreated;
|
|
255
|
+
|
|
256
|
+
async onMessage(
|
|
257
|
+
data: UserProfileCreatedEvent['data'],
|
|
258
|
+
msg: ConsumeMessage,
|
|
259
|
+
): Promise<void> {
|
|
260
|
+
console.log('User created:', data);
|
|
261
|
+
// Your business logic here
|
|
262
|
+
}
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
// Subscribe to events
|
|
266
|
+
const subscriber = new UserProfileCreatedSubscriber(channel);
|
|
267
|
+
await subscriber.subscribe();
|
|
268
|
+
```
|
|
269
|
+
|
|
270
|
+
### Features
|
|
271
|
+
|
|
272
|
+
- ✅ **Type-safe events** - Full TypeScript support with autocomplete
|
|
273
|
+
- ✅ **Centralized definitions** - All events defined in one package
|
|
274
|
+
- ✅ **Consistent naming** - Clear routing key conventions
|
|
275
|
+
- ✅ **Durable queues** - Messages persist across restarts
|
|
276
|
+
- ✅ **Error handling** - Automatic message requeuing on failures
|
|
277
|
+
- ✅ **Documentation** - Comprehensive guides and examples
|
|
278
|
+
|
|
279
|
+
### Available Events
|
|
280
|
+
|
|
281
|
+
**User Profile**: `UserProfileCreatedEvent`, `UserProfileUpdatedEvent`, `UserProfileDeletedEvent`
|
|
282
|
+
|
|
283
|
+
**Product**: `ProductCreatedEvent`, `ProductUpdatedEvent`, `ProductDeletedEvent`, `ProductStockChangedEvent`
|
|
284
|
+
|
|
285
|
+
**Order**: `OrderCreatedEvent`, `OrderUpdatedEvent`, `OrderCompletedEvent`, `OrderCancelledEvent`
|
|
286
|
+
|
|
287
|
+
### Routing Key Convention
|
|
288
|
+
|
|
289
|
+
Format: `<service>.<entity>.<action>`
|
|
290
|
+
|
|
291
|
+
Examples:
|
|
292
|
+
|
|
293
|
+
- `user_profile.profile.created`
|
|
294
|
+
- `product.product.updated`
|
|
295
|
+
- `order.order.completed`
|
|
296
|
+
|
|
297
|
+
### Documentation
|
|
298
|
+
|
|
299
|
+
- 📚 [Full Event System Documentation](src/events/README.md)
|
|
300
|
+
- 📋 [Event Guidelines](EVENT_GUIDELINES.md)
|
|
301
|
+
- 🚀 [Quick Reference](QUICK_REFERENCE.md)
|
|
302
|
+
- 🔄 [Migration Guide](MIGRATION.md)
|
|
303
|
+
|
|
304
|
+
## Logging
|
|
305
|
+
|
|
306
|
+
```typescript
|
|
307
|
+
import { Logger, createLogger, requestLogger } from '@myfoto/common-shared';
|
|
308
|
+
|
|
309
|
+
// Use default logger
|
|
310
|
+
import { log } from '@glow-up/common-shared';
|
|
311
|
+
|
|
312
|
+
log.info('Application started');
|
|
313
|
+
log.error('Something went wrong', error, { userId: '123' });
|
|
314
|
+
|
|
315
|
+
// Create custom logger
|
|
316
|
+
const logger = createLogger({
|
|
317
|
+
level: 'debug',
|
|
318
|
+
enableFile: true,
|
|
319
|
+
filePath: './logs/app.log',
|
|
320
|
+
});
|
|
321
|
+
|
|
322
|
+
// Add request logging middleware
|
|
323
|
+
app.use(requestLogger(logger));
|
|
324
|
+
|
|
325
|
+
// Performance logging
|
|
326
|
+
import { timeOperation } from '@glow-up/common-shared';
|
|
327
|
+
|
|
328
|
+
const result = await timeOperation(
|
|
329
|
+
'database-query',
|
|
330
|
+
() => prisma.user.findMany(),
|
|
331
|
+
logger,
|
|
332
|
+
);
|
|
333
|
+
```
|
|
334
|
+
|
|
335
|
+
## Validation Patterns
|
|
336
|
+
|
|
337
|
+
```typescript
|
|
338
|
+
import { ValidationPatterns } from '@glow-up/common-shared';
|
|
339
|
+
|
|
340
|
+
// Email with normalization
|
|
341
|
+
ValidationPatterns.email();
|
|
342
|
+
|
|
343
|
+
// Strong password requirements
|
|
344
|
+
ValidationPatterns.password();
|
|
345
|
+
|
|
346
|
+
// UUID validation
|
|
347
|
+
ValidationPatterns.uuid();
|
|
348
|
+
|
|
349
|
+
// Pagination parameters
|
|
350
|
+
ValidationPatterns.pagination();
|
|
351
|
+
|
|
352
|
+
// Phone number
|
|
353
|
+
ValidationPatterns.phoneNumber();
|
|
354
|
+
|
|
355
|
+
// Custom enum with case insensitive matching
|
|
356
|
+
ValidationPatterns.enumCaseInsensitive(['ACTIVE', 'INACTIVE']);
|
|
357
|
+
```
|
|
358
|
+
|
|
359
|
+
## TypeScript Support
|
|
360
|
+
|
|
361
|
+
This package is built with TypeScript and provides full type definitions. All utilities are properly typed for the best development experience.
|
|
362
|
+
|
|
363
|
+
```typescript
|
|
364
|
+
// Types are automatically inferred
|
|
365
|
+
import {
|
|
366
|
+
ApiResponse,
|
|
367
|
+
PaginatedResponse,
|
|
368
|
+
LogLevel,
|
|
369
|
+
} from '@glow-up/common-shared';
|
|
370
|
+
|
|
371
|
+
// Extend Express types (automatically included)
|
|
372
|
+
declare global {
|
|
373
|
+
namespace Express {
|
|
374
|
+
interface Request {
|
|
375
|
+
user?: {
|
|
376
|
+
id: string;
|
|
377
|
+
email: string;
|
|
378
|
+
roles?: string[];
|
|
379
|
+
};
|
|
380
|
+
}
|
|
381
|
+
interface Response {
|
|
382
|
+
success: (data?: any, message?: string) => void;
|
|
383
|
+
error: (errors: any, message?: string, statusCode?: number) => void;
|
|
384
|
+
// ... other response methods
|
|
385
|
+
}
|
|
386
|
+
}
|
|
387
|
+
}
|
|
388
|
+
```
|
|
389
|
+
|
|
390
|
+
## Peer Dependencies
|
|
391
|
+
|
|
392
|
+
Make sure to install peer dependencies if you're using related features:
|
|
393
|
+
|
|
394
|
+
```bash
|
|
395
|
+
# For database utilities
|
|
396
|
+
npm install @prisma/client
|
|
397
|
+
|
|
398
|
+
# For logging to files (if using file logging)
|
|
399
|
+
npm install winston
|
|
400
|
+
```
|
|
401
|
+
|
|
402
|
+
## Contributing
|
|
403
|
+
|
|
404
|
+
This package is part of the Glow Up microservices ecosystem. When adding new utilities:
|
|
405
|
+
|
|
406
|
+
1. Follow the existing patterns and TypeScript conventions
|
|
407
|
+
2. Add proper JSDoc documentation
|
|
408
|
+
3. Include unit tests
|
|
409
|
+
4. Update this README with usage examples
|
|
410
|
+
|
|
411
|
+
## License
|
|
412
|
+
|
|
413
|
+
MIT License - see LICENSE file for details.
|
|
414
|
+
|
|
415
|
+
## Changelog
|
|
416
|
+
|
|
417
|
+
### 1.0.0
|
|
418
|
+
|
|
419
|
+
- Initial release with core utilities
|
|
420
|
+
- Error handling system
|
|
421
|
+
- Validation middleware
|
|
422
|
+
- Database utilities
|
|
423
|
+
- Response formatting
|
|
424
|
+
- Pagination helpers
|
|
425
|
+
- Logging system
|
|
426
|
+
- Password management
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"auth-events.d.ts","sourceRoot":"","sources":["../../../src/events/types/auth-events.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AACzC,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAE9C;;GAEG;AAEH,MAAM,WAAW,uBAAuB;IACtC,QAAQ,EAAE,SAAS,CAAC,WAAW,CAAC;IAChC,UAAU,EAAE,WAAW,CAAC,YAAY,CAAC;IACrC,IAAI,EAAE;QACJ,MAAM,EAAE,MAAM,CAAC;QACf,IAAI,CAAC,EAAE,MAAM,CAAC;QACd,KAAK,CAAC,EAAE,MAAM,CAAC;KAChB,CAAC;CACH;AAED,MAAM,WAAW,wBAAwB;IACvC,QAAQ,EAAE,SAAS,CAAC,WAAW,CAAC;IAChC,UAAU,EAAE,WAAW,CAAC,cAAc,CAAC;IACvC,IAAI,EAAE;QACJ,QAAQ,EAAE,OAAO,CAAC;QAClB,aAAa,EAAE,OAAO,CAAC;QACvB,eAAe,EAAE,IAAI,CAAC;KACvB,CAAC;CACH;AAED,MAAM,WAAW,oBAAoB;IACnC,QAAQ,EAAE,SAAS,CAAC,WAAW,CAAC;IAChC,UAAU,EAAE,WAAW,CAAC,gBAAgB,CAAC;IACzC,IAAI,EAAE;QACJ,UAAU,EAAE,MAAM,CAAC;QACnB,OAAO,EAAE,MAAM,CAAC;QAChB,KAAK,CAAC,EAAE,MAAM,CAAC;KAChB,CAA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itmq-utils",
|
|
3
|
-
"version": "1.0.
|
|
4
|
-
"description": "Common utilities and middleware for Easyweb microservices architecture",
|
|
5
|
-
"main": "dist/index.js",
|
|
6
|
-
"types": "dist/index.d.ts",
|
|
7
|
-
"exports": {
|
|
8
|
-
".": {
|
|
9
|
-
"require": "./dist/index.js",
|
|
10
|
-
"import": "./dist/index.js",
|
|
11
|
-
"types": "./dist/index.d.ts"
|
|
12
|
-
}
|
|
13
|
-
},
|
|
14
|
-
"files": [
|
|
15
|
-
"dist",
|
|
16
|
-
"README.md"
|
|
17
|
-
],
|
|
18
|
-
"scripts": {
|
|
19
|
-
"build": "tsc",
|
|
20
|
-
"build:watch": "tsc --watch",
|
|
21
|
-
"prepublishOnly": "npm run build",
|
|
22
|
-
"clean": "rimraf dist",
|
|
23
|
-
"test": "jest",
|
|
24
|
-
"test:watch": "jest --watch",
|
|
25
|
-
"test:coverage": "jest --coverage",
|
|
26
|
-
"lint": "eslint src/**/*.ts",
|
|
27
|
-
"lint:fix": "eslint src/**/*.ts --fix"
|
|
28
|
-
},
|
|
29
|
-
"keywords": [
|
|
30
|
-
"microservices",
|
|
31
|
-
"express",
|
|
32
|
-
"middleware",
|
|
33
|
-
"validation",
|
|
34
|
-
"authentication",
|
|
35
|
-
"error-handling",
|
|
36
|
-
"utilities"
|
|
37
|
-
],
|
|
38
|
-
"author": "Easy Web Team",
|
|
39
|
-
"license": "MIT",
|
|
40
|
-
"repository": {
|
|
41
|
-
"type": "git",
|
|
42
|
-
"url": "https://github.com/
|
|
43
|
-
"directory": "
|
|
44
|
-
},
|
|
45
|
-
"dependencies": {
|
|
46
|
-
"amqplib": "^0.10.9",
|
|
47
|
-
"pino": "^10.3.1"
|
|
48
|
-
},
|
|
49
|
-
"devDependencies": {
|
|
50
|
-
"@types/amqplib": "^0.10.8",
|
|
51
|
-
"@types/express": "^5.0.6",
|
|
52
|
-
"@types/jest": "^29.5.14",
|
|
53
|
-
"@types/node": "^25.2.3",
|
|
54
|
-
"@typescript-eslint/eslint-plugin": "^8.56.1",
|
|
55
|
-
"@typescript-eslint/parser": "^8.56.1",
|
|
56
|
-
"eslint": "^8.50.0",
|
|
57
|
-
"jest": "^29.7.0",
|
|
58
|
-
"rimraf": "^5.0.5",
|
|
59
|
-
"ts-jest": "^29.1.1",
|
|
60
|
-
"typescript": "^5.9.3"
|
|
61
|
-
},
|
|
62
|
-
"engines": {
|
|
63
|
-
"node": ">=18.0.0"
|
|
64
|
-
},
|
|
65
|
-
"publishConfig": {
|
|
66
|
-
"access": "public"
|
|
67
|
-
}
|
|
68
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "@easyweb/rabbitmq-utils",
|
|
3
|
+
"version": "1.0.19",
|
|
4
|
+
"description": "Common utilities and middleware for Easyweb microservices architecture",
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"types": "dist/index.d.ts",
|
|
7
|
+
"exports": {
|
|
8
|
+
".": {
|
|
9
|
+
"require": "./dist/index.js",
|
|
10
|
+
"import": "./dist/index.js",
|
|
11
|
+
"types": "./dist/index.d.ts"
|
|
12
|
+
}
|
|
13
|
+
},
|
|
14
|
+
"files": [
|
|
15
|
+
"dist",
|
|
16
|
+
"README.md"
|
|
17
|
+
],
|
|
18
|
+
"scripts": {
|
|
19
|
+
"build": "tsc",
|
|
20
|
+
"build:watch": "tsc --watch",
|
|
21
|
+
"prepublishOnly": "npm run build",
|
|
22
|
+
"clean": "rimraf dist",
|
|
23
|
+
"test": "jest",
|
|
24
|
+
"test:watch": "jest --watch",
|
|
25
|
+
"test:coverage": "jest --coverage",
|
|
26
|
+
"lint": "eslint src/**/*.ts",
|
|
27
|
+
"lint:fix": "eslint src/**/*.ts --fix"
|
|
28
|
+
},
|
|
29
|
+
"keywords": [
|
|
30
|
+
"microservices",
|
|
31
|
+
"express",
|
|
32
|
+
"middleware",
|
|
33
|
+
"validation",
|
|
34
|
+
"authentication",
|
|
35
|
+
"error-handling",
|
|
36
|
+
"utilities"
|
|
37
|
+
],
|
|
38
|
+
"author": "Easy Web Team",
|
|
39
|
+
"license": "MIT",
|
|
40
|
+
"repository": {
|
|
41
|
+
"type": "git",
|
|
42
|
+
"url": "https://github.com/Alpine-Solusi/website-builder.git",
|
|
43
|
+
"directory": "server/common-shared"
|
|
44
|
+
},
|
|
45
|
+
"dependencies": {
|
|
46
|
+
"amqplib": "^0.10.9",
|
|
47
|
+
"pino": "^10.3.1"
|
|
48
|
+
},
|
|
49
|
+
"devDependencies": {
|
|
50
|
+
"@types/amqplib": "^0.10.8",
|
|
51
|
+
"@types/express": "^5.0.6",
|
|
52
|
+
"@types/jest": "^29.5.14",
|
|
53
|
+
"@types/node": "^25.2.3",
|
|
54
|
+
"@typescript-eslint/eslint-plugin": "^8.56.1",
|
|
55
|
+
"@typescript-eslint/parser": "^8.56.1",
|
|
56
|
+
"eslint": "^8.50.0",
|
|
57
|
+
"jest": "^29.7.0",
|
|
58
|
+
"rimraf": "^5.0.5",
|
|
59
|
+
"ts-jest": "^29.1.1",
|
|
60
|
+
"typescript": "^5.9.3"
|
|
61
|
+
},
|
|
62
|
+
"engines": {
|
|
63
|
+
"node": ">=18.0.0"
|
|
64
|
+
},
|
|
65
|
+
"publishConfig": {
|
|
66
|
+
"access": "public"
|
|
67
|
+
}
|
|
68
|
+
}
|