Skip to content

Instantly share code, notes, and snippets.

@mattieb
Created May 31, 2016 20:57
Show Gist options
  • Save mattieb/06e891e55f22b2d0afebaaf6fc245408 to your computer and use it in GitHub Desktop.
Save mattieb/06e891e55f22b2d0afebaaf6fc245408 to your computer and use it in GitHub Desktop.
express-winston res.end testcase
'use strict';
const express = require('express');
const expressWinston = require('express-winston');
const stream = require('stream');
const winston = require('winston');
const app = express();
const requestLogger = new expressWinston.logger(({
transports: [new winston.transports.Console({ json: true })]
}));
expressWinston.responseWhitelist.push('body');
app.all('*', requestLogger);
app.use('/', (req, res) => {
res.setHeader('Content-Type', 'application/json');
res.write('{"foo":"bar"', () => res.end('}'));
});
app.listen(8080, () => console.log('server ready on port 8080'));
{
"name": "express-winston-res-end-testcase",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "",
"license": "ISC",
"dependencies": {
"express": "^4.13.4",
"express-winston": "^1.4.0"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment