1.0.1 • Published 5 months ago

latencyjs v1.0.1

Weekly downloads
-
License
ISC
Repository
-
Last release
5 months ago

šŸš€ LatencyJS - Track API Performance & Identify Slow Requests

npm version
License: MIT
Downloads

⚔ Introduction

latencyjs is a lightweight middleware for Express.js that tracks API response times and logs slow requests using Winston. It helps in identifying performance bottlenecks in your application.

šŸŽÆ Features

āœ… Track API Response Times
āœ… Customizable Threshold (in milliseconds)
āœ… Logs Slow Requests with Warning Highlight
āœ… Lightweight & Easy to Use
āœ… Works Seamlessly with Express.js

šŸ“¦ Installation

npm install latencyjs

šŸš€ Usage Basic Setup Add latencyjs middleware to your Express app:

const express = require("express");
const latency = require("latencyjs");

const app = express();
const PORT = 3000;

// Use latencyjs middleware with a threshold of 200ms
app.use(latency(500));

app.get("/", (req, res) => {
  setTimeout(() => res.send("Hello, World!"), 550); // Simulating a slow response
});

app.listen(PORT, () => console.log(`šŸš€ Server running on port ${PORT}`));

Custom Threshold You can customize the threshold (default: 100ms):

app.use(latency(500)); // Logs requests taking longer than 500ms

šŸ“ Example Log Output

 Slow Request found => GET:/ took: 550.08 milliseconds

šŸ”„ Why Use LatencyJS? Performance Monitoring: Quickly identify slow endpoints Customizable Logging: Easily adjust the threshold Zero Configuration Required: Just plug and play 🌟 Contributing We welcome contributions! Feel free to submit issues or PRs.

Buy Me a Coffee

Your support means a lot! If you'd like to show your appreciation, you can buy me a coffee ā˜• by visiting the link below

Buy Me A Coffee

Every contribution helps keep the project alive and encourages further improvements.

šŸ“œ License This project is MIT Licensed.

1.0.1

5 months ago

1.0.0

5 months ago