yosuke-furukawa / Server Timing
This module adds [Server-Timing](https://www.w3.org/TR/server-timing/) to response headers, see [example](https://server-timing.now.sh/) and open chrome dev tool
Stars: ✭ 92
Programming Languages
javascript
184084 projects - #8 most used programming language
Projects that are alternatives of or similar to Server Timing
React Redux Saucepan
A minimal and universal react redux starter project. With hot reloading, linting and server-side rendering
Stars: ✭ 86 (-6.52%)
Mutual labels: express
Contentajs
A nodejs server that proxies to Contenta CMS and holds custom code.
Stars: ✭ 90 (-2.17%)
Mutual labels: express
Mern Social Network
A Notes App developed with MERN stack. Screenshots below. Visit the link for SPA version!! 📝 📒
Stars: ✭ 85 (-7.61%)
Mutual labels: express
Redirect Ssl
Connect/Express middleware to enforce https using is-https
Stars: ✭ 81 (-11.96%)
Mutual labels: express
Node Express React Redux Zwitter
🐣 A basic clone of Twitter (Boilerplate App) - Separate API (express+mongo) and Frontend (react+redux) folders using Node, Express, MongoDB, React (create-react-app), React Router v4 and Redux.
Stars: ✭ 91 (-1.09%)
Mutual labels: express
Hibiki
🤖 The best all-in-one Discord bot! Automod, fun, music, utilities, and more. Customizable, easy-to-use, and fully translatable.
Stars: ✭ 86 (-6.52%)
Mutual labels: express
Express App Testing Demo
a simple express app for demonstrating testing and code coverage
Stars: ✭ 89 (-3.26%)
Mutual labels: express
Web Teaching
CSE1500: lecture transcripts, slides, past exams, etc. of the web technology part of the course.
Stars: ✭ 84 (-8.7%)
Mutual labels: express
Boilerplate Vue Apollo Graphql Mongodb
Start your magical stack journey!
Stars: ✭ 85 (-7.61%)
Mutual labels: express
Fullstack Shopping Cart
MERN stack shopping cart, written in TypeScript
Stars: ✭ 82 (-10.87%)
Mutual labels: express
Svelte Template
🚧 An easy-to-use Svelte template! (Svelte + Typescript + Parcel + Express) 2020
Stars: ✭ 88 (-4.35%)
Mutual labels: express
Connect Cas2
NodeJS implement of CAS(Central Authentication Service) client.
Stars: ✭ 91 (-1.09%)
Mutual labels: express
Service Tools
Prepare your Node.js application for production
Stars: ✭ 89 (-3.26%)
Mutual labels: express
server-timing
This module adds Server-Timing to response headers. Example is here and open chrome devtool network tab.
You can use this as a express module / basic http function.
Install
$ npm install server-timing -S
Usage
const express = require('express');
const serverTiming = require('server-timing');
const app = express();
app.use(serverTiming());
app.use((req, res, next) => {
res.startTime('file', 'File IO metric');
setTimeout(() => {
res.endTime('file');
}, 100);
next();
});
app.use((req, res, next) => {
// you can see test end time response
res.startTime('test', 'forget to call endTime');
next();
});
app.use((req, res, next) => {
// All timings should be in milliseconds (s). See issue #9 (https://github.com/yosuke-furukawa/server-timing/issues/9).
res.setMetric('db', 100.0, 'Database metric');
res.setMetric('api', 200.0, 'HTTP/API metric');
res.setMetric('cache', 300.0, 'cache metric');
next();
});
app.use((req, res, next) => {
res.send('hello');
});
Conditionally enabled
const express = require('express');
const serverTiming = require('server-timing');
const app = express();
app.use(serverTiming({
// Only send metrics if query parameter `debug` is set to `true`
enabled: (req, res) => req.query.debug === 'true'
}));
API
constructor(options)
- options.name: string, default
total
, name for the timing item - options.description: string, default
Total Response Time
, explanation for the timing item - options.total: boolean, default
true
, add total response time - options.enabled: boolean | function, default
true
, enable server timing header. If a function is passed, it will be called with two arguments,request
andresponse
, and should return a boolean. - options.autoEnd: boolean, default
true
automatically endTime is called if timer is not finished. - options.precision: number, default
+Infinity
, number of decimals to use for timings.
Result
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].