Enhance configuration and authentication features across services

- Updated `next.config.js` in both web-admin and web-client to enable React strict mode, set output to standalone, and expose environment variables for API URL.
- Enhanced `auth-sdk` with detailed comments for JWT verification, decoding, and token management functions.
- Improved `http-client` with comprehensive documentation for HTTP client configuration and methods.
- Expanded `logger` functionality with detailed configuration options and logging formats.
- Enhanced `tracing` setup with detailed comments for distributed tracing configuration.
- Updated `types` definitions for authentication and user data transfer objects with comprehensive comments.
- Improved `auth-service` with detailed comments in controllers, services, and middlewares for better clarity and maintainability.
- Added health check endpoints in `health.controller.ts` for service monitoring.
- Enhanced error handling and logging throughout the application for better debugging and user feedback.
This commit is contained in:
Ho Ngoc Hai
2025-12-27 01:37:59 +07:00
parent 4da46b5b8e
commit 526f376c5f
24 changed files with 883 additions and 89 deletions

View File

@@ -4,23 +4,43 @@ import { JaegerExporter } from '@opentelemetry/exporter-jaeger';
import { Resource } from '@opentelemetry/resources';
import { SemanticResourceAttributes } from '@opentelemetry/semantic-conventions';
/**
* EN: Configuration interface for distributed tracing setup
* VI: Interface cấu hình cho việc thiết lập distributed tracing
*/
export interface TracingConfig {
/** EN: Name of the service for trace identification / VI: Tên service để xác định trace */
serviceName: string;
/** EN: Jaeger collector endpoint URL / VI: URL endpoint Jaeger collector */
jaegerEndpoint?: string;
/** EN: Enable/disable tracing (default: true) / VI: Bật/tắt tracing (mặc định: true) */
enabled?: boolean;
}
/**
* EN: Initialize OpenTelemetry distributed tracing with Jaeger exporter
* VI: Khởi tạo OpenTelemetry distributed tracing với Jaeger exporter
*
* @param config - Tracing configuration / Cấu hình tracing
* @returns NodeSDK instance or null if tracing is disabled / Instance NodeSDK hoặc null nếu tracing bị tắt
*/
export const initTracing = (config: TracingConfig): NodeSDK | null => {
// EN: Return null if tracing is explicitly disabled
// VI: Trả về null nếu tracing bị tắt rõ ràng
if (config.enabled === false) {
return null;
}
// EN: Create Jaeger exporter if endpoint is provided
// VI: Tạo Jaeger exporter nếu endpoint được cung cấp
const jaegerExporter = config.jaegerEndpoint
? new JaegerExporter({
endpoint: config.jaegerEndpoint,
})
: undefined;
// EN: Initialize OpenTelemetry NodeSDK with auto-instrumentations
// VI: Khởi tạo OpenTelemetry NodeSDK với auto-instrumentations
const sdk = new NodeSDK({
resource: new Resource({
[SemanticResourceAttributes.SERVICE_NAME]: config.serviceName,
@@ -29,9 +49,13 @@ export const initTracing = (config: TracingConfig): NodeSDK | null => {
instrumentations: [getNodeAutoInstrumentations()],
});
// EN: Start the tracing SDK
// VI: Khởi động tracing SDK
sdk.start();
return sdk;
};
// EN: Default export for the initTracing function
// VI: Export default cho hàm initTracing
export default initTracing;