UNPKG

@cnbcool/mcp-server

Version:

CNB MCP Server. A comprehensive MCP server that provides seamless integration to the CNB's API(https://cnb.cool), offering a wide range of tools for repository management, pipelines operations and collaboration features

50 lines (49 loc) 1.9 kB
"use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); exports.logMiddleware = logMiddleware; const node_crypto_1 = require("node:crypto"); const winston_1 = __importDefault(require("winston")); const logger = winston_1.default.createLogger({ level: 'info', format: winston_1.default.format.combine(winston_1.default.format.timestamp(), winston_1.default.format.errors({ stack: true }), winston_1.default.format.json()), defaultMeta: { service: 'cnb-mcp-server' }, transports: [ new winston_1.default.transports.Console({ format: winston_1.default.format.combine(winston_1.default.format.colorize(), winston_1.default.format.simple()) }) ] }); function logMiddleware(req, res, next) { var _a; const startTime = Date.now(); const requestId = (0, node_crypto_1.randomUUID)(); logger.info('Incoming request', { method: req.method, url: req.url, headers: { traceparent: req.headers['traceparent'] }, body: req.body ? JSON.stringify(req.body).substring(0, 500) : undefined, ip: req.headers['x-client-ip'] || req.headers['x-real-ip'] || req.ip || req.connection.remoteAddress, authLength: (_a = req.headers['authorization']) === null || _a === void 0 ? void 0 : _a.length, requestId }); res.on('finish', () => { logger.info('Request finished', { statusCode: res.statusCode, duration: Date.now() - startTime, requestId }); }); res.on('close', () => { logger.info('Request closed', { statusCode: res.statusCode, duration: Date.now() - startTime, requestId }); }); next(); }