express-response-timestamp

1.0.0 • Public • Published

Express Response Timestamp

Zero Dependencies

Usage

import express from "express";
import timestampHandler from "../index.js";

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:

{
  "foo": "bar",
  "framework": "express",
  "timestamp": "Mon, 20 Dec 2021 17:57:00 GMT"
}

Licence

MIT

Readme

Keywords

none

Package Sidebar

Install

npm i express-response-timestamp

Weekly Downloads

1

Version

1.0.0

License

MIT

Unpacked Size

2.32 kB

Total Files

5

Last publish

Collaborators

  • ultirequiem