Demo server for morgan-mongo middleware with additional geo-ip functionality.
git clone https://github.com/pmstss/morgan-mongo-demo
cd morgan-mongo-demo
npm install
npm run start
After that server should be accessible by default at http://localhost:3000 (port can be changed in sources or via environment variable PORT
).
It will records parsed morgan entries (request and response meta) into local mongo instance with default parameters:
- connection string:
mongodb://localhost:27017/morgan-mongo
; env var to override:MONGO_MORGAN_URI
- database name:
morgan-mongo
(envMONGO_MORGAN_DB
) - collection name:
request-logs
(envMONGO_MORGAN_COLLECTION
) - geo data collection name:
geoip
(envMONGO_MORGAN_COLLECTION_GEO
)
Sample output of geo data:
Expand
{
"as" : "AS15169 Google LLC",
"city" : "Mountain View",
"country" : "United States",
"countryCode" : "US",
"isp" : "Level 3 Communications",
"lat" : 37.4229,
"lon" : -122.085,
"org" : "Google Inc.",
"query" : "8.8.8.8",
"region" : "CA",
"regionName" : "California",
"status" : "success",
"timezone" : "America/Los_Angeles",
"zip" : "94043"
}
Note: local ips are filtered with is-local-ip library, geo data for them will contain only local: true
flag.
It will records geo-ip data to local mongo (with default connection string mongodb://localhost:27017/morgan-mongo) into geoip collection (can be tuned either in sources or by setting environment variables).
- ip-api - IP Geolocation API service
Feel free to contribute by opening issues with any questions, bug reports or feature requests.