https://github.com/doowb/request-info
Get information about an http request.
https://github.com/doowb/request-info
Last synced: 7 days ago
JSON representation
Get information about an http request.
- Host: GitHub
- URL: https://github.com/doowb/request-info
- Owner: doowb
- License: mit
- Created: 2016-08-30T00:53:04.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2021-07-21T00:41:05.000Z (almost 4 years ago)
- Last Synced: 2025-03-31T15:21:53.139Z (26 days ago)
- Language: JavaScript
- Size: 17.6 KB
- Stars: 8
- Watchers: 4
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Contributing: .github/CONTRIBUTING.md
- Funding: .github/FUNDING.yml
- License: LICENSE
Awesome Lists containing this project
README
# request-info [](https://www.npmjs.com/package/request-info) [](https://npmjs.org/package/request-info) [](https://npmjs.org/package/request-info)
> Get information about an http request.
Please consider following this project's author, [Brian Woodward](https://github.com/doowb), and consider starring the project to show your :heart: and support.
## Install
Install with [npm](https://www.npmjs.com/) (requires [Node.js](https://nodejs.org/en/) >=0.10.0):
```sh
$ npm install --save request-info
```## Usage
```js
const info = require('request-info');
const express = require('express');
const app = express();app.get('/', (req, res) => {
console.log(info(req)); // see below for details
});
```## API
**Params**
* `req` **{Object}**: http request object (from http or express)
* `returns` **{Object}**: info object containing `httpVersion`, `ip`, `method`, `referer`, `url`, and `ua` (useragent information)**Example**
```js
const express = require('express');
const app = express();app.get('/', (req, res) => {
console.log(info(req));
// {
// httpVersion: '1.1',
// ip: '127.0.0.1',
// method: 'GET',
// referer: 'http://localhost:8080/index.html',
// url: '/',
// ua: {
// ua: 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/52.0.2743.116 Safari/537.36',
// browser: { name: 'Chrome', version: '52.0.2743.116', major: '52' },
// engine: { version: '537.36', name: 'WebKit' },
// os: { name: 'Mac OS', version: '10.9.5' },
// device: { model: undefined, vendor: undefined, type: undefined },
// cpu: { architecture: undefined }
// }
// }
});
```## Acknowledgments
Some of the code has been adapted from https://github.com/joola/joola.io.express/blob/master/index.js#L39-L50
## About
Contributing
Pull requests and stars are always welcome. For bugs and feature requests, [please create an issue](../../issues/new).
Running Tests
Running and reviewing unit tests is a great way to get familiarized with a library and its API. You can install dependencies and run tests with the following command:
```sh
$ npm install && npm test
```Building docs
_(This project's readme.md is generated by [verb](https://github.com/verbose/verb-generate-readme), please don't edit the readme directly. Any changes to the readme must be made in the [.verb.md](.verb.md) readme template.)_
To generate the readme, run the following command:
```sh
$ npm install -g verbose/verb#dev verb-generate-readme && verb
```### Related projects
You might also be interested in these projects:
* [generate-webtask](https://www.npmjs.com/package/generate-webtask): Generate a starting point for a webtask.io service. | [homepage](https://github.com/generate/generate-webtask "Generate a starting point for a webtask.io service.")
* [gh-clone](https://www.npmjs.com/package/gh-clone): git clone a repo with only username/repo, or if it's an NPM package you can… [more](https://github.com/jonschlinkert/gh-clone) | [homepage](https://github.com/jonschlinkert/gh-clone "git clone a repo with only username/repo, or if it's an NPM package you can use just the name of the project.")
* [gulp-bundle-webtask](https://www.npmjs.com/package/gulp-bundle-webtask): Gulp plugin for browserifying and bundling your source code before deploying to webtask.io. | [homepage](https://github.com/doowb/gulp-bundle-webtask "Gulp plugin for browserifying and bundling your source code before deploying to webtask.io.")### Author
**Brian Woodward**
* [GitHub Profile](https://github.com/doowb)
* [Twitter Profile](https://twitter.com/doowb)
* [LinkedIn Profile](https://linkedin.com/in/woodwardbrian)### License
Copyright © 2021, [Brian Woodward](https://github.com/doowb).
Released under the [MIT License](LICENSE).***
_This file was generated by [verb-generate-readme](https://github.com/verbose/verb-generate-readme), v0.8.0, on July 20, 2021._