
Security News
Open Source Maintainers Feeling the Weight of the EU’s Cyber Resilience Act
The EU Cyber Resilience Act is prompting compliance requests that open source maintainers may not be obligated or equipped to handle.
api-stats-logger
Advanced tools
SDK completo de logging e monitoramento de APIs com nova estrutura de logs organizada, auto-instrumentação, dashboard em tempo real e CLI para configuração automática. Suporta logs estruturados por contexto (HTTP, business, security, system) com campos op
SDK profissional para logging e monitoramento de APIs em Node.js com instrumentação automática.
npm install api-stats-logger
npx api-stats-init
Este comando irá:
const ApiStatsLogger = require('api-stats-logger');
const logger = new ApiStatsLogger({
apiKey: process.env.API_STATS_API_KEY,
service: 'minha-api',
environment: 'production'
});
// Logging manual
logger.info('Usuário logado', { userId: 123 });
logger.error('Erro no banco', { error: 'timeout' });
const express = require('express');
const ApiStatsLogger = require('api-stats-logger');
const app = express();
const logger = new ApiStatsLogger();
// Middleware automático
app.use(ApiStatsLogger.expressMiddleware({ logger }));
app.listen(3000);
// Adicione no main.ts
import { ApiStatsLogger } from 'api-stats-logger';
async function bootstrap() {
const app = await NestFactory.create(AppModule);
const logger = new ApiStatsLogger();
app.use(ApiStatsLogger.nestMiddleware({ logger }));
await app.listen(3000);
}
// Fastify
fastify.register(ApiStatsLogger.fastifyPlugin());
// Koa
app.use(ApiStatsLogger.koaMiddleware());
const logger = new ApiStatsLogger({
apiKey: process.env.API_STATS_API_KEY,
service: 'minha-api',
environment: 'production',
// Performance
batchSize: 50,
flushInterval: 5000,
maxRetries: 3,
// Recursos
captureErrors: true,
capturePerformance: true,
// Segurança
captureBody: false,
captureHeaders: false
});
O SDK automaticamente filtra headers sensíveis:
authorization
cookie
x-api-key
x-auth-token
async function processPayment(paymentData) {
const operationId = `payment_${Date.now()}`;
logger.info('Payment started', { operationId, amount: paymentData.amount });
try {
const result = await paymentGateway.process(paymentData);
logger.info('Payment completed', { operationId, paymentId: result.id });
return result;
} catch (error) {
logger.error('Payment failed', { operationId, error: error.message });
throw error;
}
}
// Express middleware customizado
app.use(ApiStatsLogger.expressMiddleware({
logger,
captureBody: false,
captureHeaders: false,
skipPaths: ['/health', '/metrics']
}));
# Obrigatório
API_STATS_API_KEY=sua-api-key-aqui
# Opcionais
API_STATS_SERVICE=minha-api
API_STATS_ENVIRONMENT=production
API_STATS_URL=https://api.exemplo.com/logs
API_STATS_ENABLED=true
API_STATS_BATCH_SIZE=20
API_STATS_FLUSH_INTERVAL=5000
MIT License - veja LICENSE para detalhes.
Desenvolvido com ❤️ para desenvolvedores Node.js
FAQs
SDK completo de logging e monitoramento de APIs com nova estrutura de logs organizada, auto-instrumentação, dashboard em tempo real e CLI para configuração automática. Suporta logs estruturados por contexto (HTTP, business, security, system) com campos op
The npm package api-stats-logger receives a total of 1,582 weekly downloads. As such, api-stats-logger popularity was classified as popular.
We found that api-stats-logger demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
The EU Cyber Resilience Act is prompting compliance requests that open source maintainers may not be obligated or equipped to handle.
Security News
Crates.io adds Trusted Publishing support, enabling secure GitHub Actions-based crate releases without long-lived API tokens.
Research
/Security News
Undocumented protestware found in 28 npm packages disrupts UI for Russian-language users visiting Russian and Belarusian domains.