https://github.com/nshimiye/express-request-capture
Typescript version of Clearonline's capture
https://github.com/nshimiye/express-request-capture
expressjs logger logging nodejs
Last synced: 5 months ago
JSON representation
Typescript version of Clearonline's capture
- Host: GitHub
- URL: https://github.com/nshimiye/express-request-capture
- Owner: nshimiye
- License: mit
- Created: 2017-10-17T06:24:58.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2020-06-02T18:28:13.000Z (about 6 years ago)
- Last Synced: 2025-07-01T10:48:11.037Z (12 months ago)
- Topics: expressjs, logger, logging, nodejs
- Language: TypeScript
- Size: 4.18 MB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 38
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
- Code of conduct: code-of-conduct.md
Awesome Lists containing this project
README
# Express Request Capture
Node.js express middleware for capturing HTTP requests and responses
[](https://github.com/prettier/prettier)
[](https://greenkeeper.io/)
[](https://travis-ci.org/nshimiye/express-request-capture)
[](https://codecov.io/gh/nshimiye/express-request-capture)
[](https://david-dm.org/nshimiye/express-request-capture?type=dev)
[](https://paypal.me/nshimiyetech)
### API
```js
var requestCapture = require ('express-request-capture')
```
* requestCapture ({ channel: string, url?: string })
When using this module with express or connect, simply `app.use` the module.
Request information `url, request, response, status, latency, and clientIp`, is printed/stored to the specified channel!
```js
var requestCapture = require ('express-request-capture'),
express = require ('express')
var app = express()
var printAdapter = { channel: 'console|http', url: 'required if channel is either http' };
app.use(requestCapture(printAdapter))
```
```js
// sample response
{
url: "https://alert.clearonline.org/api/v1/subscribe",
method: "POST",
status: 200,
latency: 100,
request: {
headers: {
"Content-Type": "application/json"
},
body: {
email: "hello@clearonline.org",
trigger: "solar energy"
},
host: "localhost:3000",
clientIp: "192.111.1.1"
},
response: {
header: {
"Date": "2017-06-02T22:29:44.315Z"
},
body: {
message: "Thank you for subscribing, i will send you notes every monday!"
}
}
}
```
### Examples
### Packaging
* use of `jsnext:main`: https://github.com/jsforum/jsforum/issues/5
### Resource
* [Using Superset for acceptence testing](http://www.albertgao.xyz/2017/05/24/how-to-test-expressjs-with-jest-and-supertest/)