Skip to content

Instantly share code, notes, and snippets.

View jcperez's full-sized avatar
🙃

Juan Carlos Pérez jcperez

🙃
View GitHub Profile

AKIAJCNXDPKYNSY3AQ3Q

function logger(message) {
console.log(`${session.get('request-id')} - ${message}`);
}
app.get('/', (req, res) => {
logger(`Request to ${req.path}`);
res.send(`Request completed - ${session.get('request-id')}`);
});
const express = require('express');
const app = express();
const namespace = require('cls-hooked').createNamespace;
const session = namespace('demo-session');
function createNamespace(req, res, next) {
session.run(function () {
const requestId = req.get('request-id') || generateRequestId();
session.set('request-id', requestId);

Keybase proof

I hereby claim:

  • I am jcperez on github.
  • I am jc_perez91 (https://keybase.io/jc_perez91) on keybase.
  • I have a public key ASDt_BIUBLuHmZEDv_XaYGu347GvkAzenw0xo0mfGIyIwwo

To claim this, I am signing this object: