Security News
GitHub Removes Malicious Pull Requests Targeting Open Source Repositories
GitHub removed 27 malicious pull requests attempting to inject harmful code across multiple open source repositories, in another round of low-effort attacks.
server-timestamp
Advanced tools
Create a middleware to add a server timestamp header in milliseconds. Use for Express
Create a middleware to add a server timestamp header in milliseconds. Use for Express
This is a Node.js module available through the
npm registry. Installation is done using the
npm install
command:
$ npm install --save server-timestamp
var serverTimestamp = require('server-timestamp');
Create a middleware that adds a X-Server-Timestamp
header to responses. If
you don't want to use this module to automatically set a header, please
see the section about Options format
The serverTimestamp
function accepts an optional options
object that may
contain any of the following keys:
The name of the header to set, defaults to X-Server-Timestamp.
This is a function that formats timestamps.
var serverTimestamp = require('./');
var express = require('express');
var app = express();
app.use(serverTimestamp());
// response
app.get('/', function (req, res) {
/*
res results:
{
"x-powered-by": "Express",
"x-server-timestamp": 1493365865576
}
*/
res.send(res._headers)
});
app.listen(3000, function () {
console.log('Example app listening on port 3000!')
});
var serverTimestamp = require('./');
var express = require('express');
var app = express();
app.use(serverTimestamp({header: 'Example-Server-Timestamp'}));
// response
app.get('/', function (req, res) {
/*
res results:
{
"x-powered-by": "Express",
"example-server-timestamp": 1493365865576
}
*/
res.send(res._headers)
});
app.listen(3000, function () {
console.log('Example app listening on port 3000!')
});
var serverTimestamp = require('./');
var express = require('express');
var app = express();
app.use(serverTimestamp({
header: 'Example-Format-Server-Timestamp',
format: function(timestamp){
var now = new Date(timestamp);
var year = now.getFullYear();
var month = now.getMonth() + 1;
var date = now.getDate();
var hour = now.getHours();
var minute = now.getMinutes();
var second = now.getSeconds();
return year + '-' + month + '-' + date + ' '+ hour + ':' + minute + ':' + second;
}
}));
// response
app.get('/', function (req, res) {
/*
res results:
{
"x-powered-by": "Express",
"example-format-server-timestamp": "2017-4-28 15:51:5"
}
*/
res.send(res._headers)
});
app.listen(3000, function () {
console.log('Example app listening on port 3000!')
});
Check this repo for full example with Express
.
FAQs
Create a middleware to add a server timestamp header in milliseconds. Use for Express
The npm package server-timestamp receives a total of 1 weekly downloads. As such, server-timestamp popularity was classified as not popular.
We found that server-timestamp 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
GitHub removed 27 malicious pull requests attempting to inject harmful code across multiple open source repositories, in another round of low-effort attacks.
Security News
RubyGems.org has added a new "maintainer" role that allows for publishing new versions of gems. This new permission type is aimed at improving security for gem owners and the service overall.
Security News
Node.js will be enforcing stricter semver-major PR policies a month before major releases to enhance stability and ensure reliable release candidates.