All Projects → expressjs → Response Time

expressjs / Response Time

Licence: mit
Response time header for node.js

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to Response Time

Miox
Modern infrastructure of complex SPA
Stars: ✭ 374 (-13.02%)
Mutual labels:  middleware
Concurrency Logger
Log HTTP requests/responses separately, visualize their concurrency and report logs/errors in context of a request.
Stars: ✭ 400 (-6.98%)
Mutual labels:  middleware
Swift Web
🕸 A collection of Swift server-side frameworks for handling HTML, CSS, routing and middleware.
Stars: ✭ 415 (-3.49%)
Mutual labels:  middleware
Transmittable Thread Local
📌 TransmittableThreadLocal (TTL), the missing Java™ std lib(simple & 0-dependency) for framework/middleware, provide an enhanced InheritableThreadLocal that transmits values between threads even using thread pooling components.
Stars: ✭ 4,678 (+987.91%)
Mutual labels:  middleware
Cerberus
一款功能强大的漏洞扫描器,子域名爆破使用aioDNS,asyncio异步快速扫描,覆盖目标全方位资产进行批量漏洞扫描,中间件信息收集,自动收集ip代理,探测Waf信息时自动使用来保护本机真实Ip,在本机Ip被Waf杀死后,自动切换代理Ip进行扫描,Waf信息收集(国内外100+款waf信息)包括安全狗,云锁,阿里云,云盾,腾讯云等,提供部分已知waf bypass 方案,中间件漏洞检测(Thinkphp,weblogic等 CVE-2018-5955,CVE-2018-12613,CVE-2018-11759等),支持SQL注入, XSS, 命令执行,文件包含, ssrf 漏洞扫描, 支持自定义漏洞邮箱推送功能
Stars: ✭ 389 (-9.53%)
Mutual labels:  middleware
Slim Basic Auth
PSR-7 and PSR-15 HTTP Basic Authentication Middleware
Stars: ✭ 402 (-6.51%)
Mutual labels:  middleware
Client ruby
Prometheus instrumentation library for Ruby applications
Stars: ✭ 369 (-14.19%)
Mutual labels:  middleware
Resty
Simple HTTP and REST client library for Go
Stars: ✭ 5,368 (+1148.37%)
Mutual labels:  middleware
Diet
A tiny, fast and modular node.js web framework. Good for making fast & scalable apps and apis.
Stars: ✭ 394 (-8.37%)
Mutual labels:  middleware
Echo Web
Go web framework Echo example. 在线演示☞迁移ing❌
Stars: ✭ 409 (-4.88%)
Mutual labels:  middleware
Echo
High performance, minimalist Go web framework
Stars: ✭ 21,297 (+4852.79%)
Mutual labels:  middleware
Errorhandler
Development-only error handler middleware
Stars: ✭ 386 (-10.23%)
Mutual labels:  middleware
Defender
Roles & Permissions for Laravel 8 / 7 / 6 / 5
Stars: ✭ 403 (-6.28%)
Mutual labels:  middleware
Krakend
Ultra performant API Gateway with middlewares. A project hosted at The Linux Foundation
Stars: ✭ 4,752 (+1005.12%)
Mutual labels:  middleware
Servicebus
Simple service bus for sending events between processes using amqp.
Stars: ✭ 415 (-3.49%)
Mutual labels:  middleware
Laravel Logger
An out the box activity logger for your Laravel or Lumen application. Laravel logger is an activity event logger for your laravel application. It comes out the box with ready to use with dashboard to view your activity. Laravel logger can be added as a middleware or called through a trait. This package is easily configurable and customizable. Supports Laravel 5.3, 5.4, 5.5, 5.6, 5.7, 5.8, 6, and 7+
Stars: ✭ 366 (-14.88%)
Mutual labels:  middleware
Websocket Manager
Real-Time library for ASP .NET Core
Stars: ✭ 400 (-6.98%)
Mutual labels:  middleware
Koa Webpack
Development and Hot Reload Middleware for Koa2
Stars: ✭ 429 (-0.23%)
Mutual labels:  middleware
Permissions2
🔐 Middleware for keeping track of users, login states and permissions
Stars: ✭ 423 (-1.63%)
Mutual labels:  middleware
Persistgraphql
A build tool for GraphQL projects.
Stars: ✭ 409 (-4.88%)
Mutual labels:  middleware

response-time

NPM Version NPM Downloads Build Status Test Coverage

Response time for Node.js servers.

This module creates a middleware that records the response time for requests in HTTP servers. The "response time" is defined here as the elapsed time from when a request enters this middleware to when the headers are written out to the client.

Installation

This is a Node.js module available through the npm registry. Installation is done using the npm install command:

$ npm install response-time

API

var responseTime = require('response-time')

responseTime([options])

Create a middleware that adds a X-Response-Time header to responses. If you don't want to use this module to automatically set a header, please see the section about responseTime(fn).

Options

The responseTime function accepts an optional options object that may contain any of the following keys:

digits

The fixed number of digits to include in the output, which is always in milliseconds, defaults to 3 (ex: 2.300ms).

header

The name of the header to set, defaults to X-Response-Time.

suffix

Boolean to indicate if units of measurement suffix should be added to the output, defaults to true (ex: 2.300ms vs 2.300).

responseTime(fn)

Create a new middleware that records the response time of a request and makes this available to your own function fn. The fn argument will be invoked as fn(req, res, time), where time is a number in milliseconds.

Examples

express/connect

var express = require('express')
var responseTime = require('response-time')

var app = express()

app.use(responseTime())

app.get('/', function (req, res) {
  res.send('hello, world!')
})

vanilla http server

var finalhandler = require('finalhandler')
var http = require('http')
var responseTime = require('response-time')

// create "middleware"
var _responseTime = responseTime()

http.createServer(function (req, res) {
  var done = finalhandler(req, res)
  _responseTime(req, res, function (err) {
    if (err) return done(err)

    // respond to request
    res.setHeader('content-type', 'text/plain')
    res.end('hello, world!')
  })
})

response time metrics

var express = require('express')
var responseTime = require('response-time')
var StatsD = require('node-statsd')

var app = express()
var stats = new StatsD()

stats.socket.on('error', function (error) {
  console.error(error.stack)
})

app.use(responseTime(function (req, res, time) {
  var stat = (req.method + req.url).toLowerCase()
    .replace(/[:.]/g, '')
    .replace(/\//g, '_')
  stats.timing(stat, time)
}))

app.get('/', function (req, res) {
  res.send('hello, world!')
})

License

MIT

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].