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
import contextlib | |
import ctypes | |
import ctypes.wintypes | |
import io | |
import json | |
import os | |
import re | |
import socket | |
import socketserver | |
import threading |
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 _jsonParser = express.json({ limit: '100mb' }); | |
// hijack jsonParser to log JSON bodies | |
console.log('installing jsonParser hijack') | |
const jsonParser = (req, res, next) => { | |
console.log('jsonParser called @', req.method, req.url); | |
_jsonParser(req, res, (next_retval) => { | |
// log if JSON request | |
if (req.headers && req.headers['content-type'] && req.headers['content-type'].startsWith('application/json') && req.body) { | |
let fname = `${humanizedISO8601DateTime()}-${req.url.replace(/\//g, '')}.json`.replace(/ /g, '_') | |
let _path = path.join(__dirname, 'debugLogs', fname) |