
Security News
npm Adopts OIDC for Trusted Publishing in CI/CD Workflows
npm now supports Trusted Publishing with OIDC, enabling secure package publishing directly from CI/CD workflows without relying on long-lived tokens.
server-timing
Advanced tools
This module can add `ServerTiming` Header to http response, and be able to use express middleware
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.
$ npm install server-timing -S
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');
});
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'
}));
total
, name for the timing itemTotal Response Time
, explanation for the timing itemtrue
, add total response timetrue
, enable server timing header. If a function is passed, it will be called with two arguments, request
and response
, and should return a boolean.true
automatically endTime is called if timer is not finished.+Infinity
, number of decimals to use for timings.FAQs
This module can add `ServerTiming` Header to http response, and be able to use express middleware
The npm package server-timing receives a total of 14,674 weekly downloads. As such, server-timing popularity was classified as popular.
We found that server-timing demonstrated a not healthy version release cadence and project activity because the last version was released 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
npm now supports Trusted Publishing with OIDC, enabling secure package publishing directly from CI/CD workflows without relying on long-lived tokens.
Research
/Security News
A RubyGems malware campaign used 60 malicious packages posing as automation tools to steal credentials from social media and marketing tool users.
Security News
The CNA Scorecard ranks CVE issuers by data completeness, revealing major gaps in patch info and software identifiers across thousands of vulnerabilities.