AKIAJCNXDPKYNSY3AQ3Q
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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')}`); | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); |
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: