Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/ultirequiem/express-response-timestamp
💨 Middleware to add a timestamp to every response.json()
https://github.com/ultirequiem/express-response-timestamp
express express-middleware nodejs
Last synced: 3 months ago
JSON representation
💨 Middleware to add a timestamp to every response.json()
- Host: GitHub
- URL: https://github.com/ultirequiem/express-response-timestamp
- Owner: UltiRequiem
- License: mit
- Created: 2021-12-20T17:22:23.000Z (about 3 years ago)
- Default Branch: main
- Last Pushed: 2023-02-04T04:17:58.000Z (almost 2 years ago)
- Last Synced: 2024-10-04T19:27:24.885Z (3 months ago)
- Topics: express, express-middleware, nodejs
- Language: JavaScript
- Homepage: https://npm.im/express-response-timestamp
- Size: 115 KB
- Stars: 6
- Watchers: 2
- Forks: 3
- Open Issues: 1
-
Metadata Files:
- Readme: readme.md
- License: license
Awesome Lists containing this project
README
# Express Response Timestamp
Middleware to add a timestamp to every `response.json()`, zero dependencies.
## Usage
```js
import express from "express";
import timestampHandler from "express-response-timestamp";const app = express();
const PORT = 3005;
app.use(timestampHandler()); // Default: `() => new Date().toUTCString()`
// app.use(timestampHandler(() => new Date().toLocaleDateString()));
// app.use(timestampHandler(moment().year));app.use("/", (_request, response) => {
response.json({ foo: "bar", framework: "express" });
});app.listen(PORT, () => {
console.log(`Server listening http://localhost:${PORT}`);
});
```The response of `/` is:
```json
{
"foo": "bar",
"framework": "express",
"timestamp": "Mon, 20 Dec 2021 17:57:00 GMT"
}
```## Licence
MIT