feat(logging): add comprehensive API request/response logging with structured winston logs

- Add dedicated API logger (api-logger.ts) with winston daily rotation
- Create Fastify plugin (api-logging.plugin.ts) to intercept all API requests/responses
- Log request start, body, response, errors, and summary with precise timestamps
- Auto-mask sensitive data using existing sanitizeObject utility
- Register API logging plugin in NestJS bootstrap (server/main.ts)
- Add npm run dev script with cross-env for automatic DEBUG on Windows
- Install cross-env as devDependency for cross-platform env vars
This commit is contained in:
Gemini Nexus Bot committed 2026-04-22 00:07:30 -03:00
1 parent faabf7ba7a
commit 27da62afc9
5 files changed
+268 -11

No files matched your search

+5
View File
@@ -7,6 +7,7 @@ import { TokenManagerService } from './modules/proxy/token-manager.service';
import { ProxyConfig } from '../types/config';
import { setServerConfig } from './server-config';
import { registerApiLogging } from './logging/api-logging.plugin';
let app: NestFastifyApplication | null = null;
let currentPort: number = 0;
@@ -28,6 +29,10 @@ export async function bootstrapNestServer(config: ProxyConfig): Promise<boolean>
// Enable CORS
app.enableCors();
// Register detailed API request/response logging
const fastifyInstance = app.getHttpAdapter().getInstance();
await registerApiLogging(fastifyInstance);
await app.listen(port, '0.0.0.0');
currentPort = port;
logger.info(`NestJS Proxy Server running on http://localhost:${port}`);