Created
May 31, 2016 20:57
-
-
Save mattieb/06e891e55f22b2d0afebaaf6fc245408 to your computer and use it in GitHub Desktop.
express-winston res.end testcase
This file contains hidden or 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
'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')); |
This file contains hidden or 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
{ | |
"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