Comparing version 1.0.0 to 1.0.1
15
index.js
@@ -25,2 +25,3 @@ const url = require('url'); | ||
} | ||
// inspired by raven's parseRequest | ||
@@ -72,11 +73,12 @@ // eslint-disable-next-line complexity | ||
} | ||
middleware(ctx, next) { | ||
const req = isObject(ctx) && isObject(ctx.request) ? ctx.request : ctx; | ||
const { logger } = this.config; | ||
const getMeta = this.getMeta; | ||
const { getMeta } = this; | ||
// level, message, meta | ||
ctx.logger = function() { | ||
if (isUndefined(arguments[3]) || isNull(arguments[3])) arguments[3] = {}; | ||
if (isObject(arguments[3])) Object.assign(arguments[3], getMeta(req)); | ||
logger[arguments[0]](...[].slice.call(arguments).slice(1)); | ||
ctx.logger = function(...args) { | ||
if (isUndefined(args[3]) || isNull(args[3])) args[3] = {}; | ||
if (isObject(args[3])) Object.assign(args[3], getMeta(req)); | ||
logger[args[0]](...[].slice.call(args).slice(1)); | ||
}; | ||
@@ -86,4 +88,3 @@ // shorthand method | ||
Object.keys(logger).forEach(key => { | ||
ctx.logger[key] = function() { | ||
const args = [].slice.call(arguments); | ||
ctx.logger[key] = function(...args) { | ||
args.unshift(key); | ||
@@ -90,0 +91,0 @@ ctx.logger(...args); |
{ | ||
"name": "cabin", | ||
"description": | ||
"Cabin is a logging/analytics service and middleware for Node.js, Lad, Koa, Express, and Passport", | ||
"version": "1.0.0", | ||
"description": "Cabin is a logging/analytics service and middleware for Node.js, Lad, Koa, Express, and Passport", | ||
"version": "1.0.1", | ||
"author": "Nick Baugh <niftylettuce@gmail.com> (http://niftylettuce.com/)", | ||
@@ -15,5 +14,6 @@ "bugs": { | ||
"dependencies": { | ||
"auto-bind": "^1.2.0", | ||
"cookie": "^0.3.1", | ||
"fast-safe-stringify": "^1.2.1", | ||
"lodash": "^4.17.4" | ||
"fast-safe-stringify": "^2.0.4", | ||
"lodash": "^4.17.10" | ||
}, | ||
@@ -25,19 +25,18 @@ "ava": { | ||
"devDependencies": { | ||
"auto-bind": "^1.1.0", | ||
"ava": "^0.22.0", | ||
"codecov": "^2.3.0", | ||
"cross-env": "^5.0.5", | ||
"eslint": "^4.5.0", | ||
"eslint-config-prettier": "^2.3.0", | ||
"eslint-plugin-prettier": "^2.2.0", | ||
"express": "^4.16.2", | ||
"ava": "^0.25.0", | ||
"codecov": "^3.0.2", | ||
"cross-env": "^5.1.6", | ||
"eslint": "^4.19.1", | ||
"eslint-config-prettier": "^2.9.0", | ||
"eslint-plugin-prettier": "^2.6.0", | ||
"express": "^4.16.3", | ||
"husky": "^0.14.3", | ||
"koa": "^2.4.1", | ||
"lint-staged": "^4.0.4", | ||
"nyc": "^11.1.0", | ||
"prettier": "^1.6.1", | ||
"remark-cli": "^4.0.0", | ||
"remark-preset-github": "^0.0.6", | ||
"supertest": "^3.0.0", | ||
"xo": "^0.19.0" | ||
"koa": "^2.5.1", | ||
"lint-staged": "^7.1.3", | ||
"nyc": "^12.0.1", | ||
"prettier": "^1.13.4", | ||
"remark-cli": "^5.0.0", | ||
"remark-preset-github": "^0.0.8", | ||
"supertest": "^3.1.0", | ||
"xo": "^0.21.1" | ||
}, | ||
@@ -89,7 +88,12 @@ "homepage": "https://github.com/cabinjs/cabin", | ||
], | ||
"*.md": ["remark . -qfo", "git add"] | ||
"*.md": [ | ||
"remark . -qfo", | ||
"git add" | ||
] | ||
}, | ||
"main": "index.js", | ||
"remarkConfig": { | ||
"plugins": ["preset-github"] | ||
"plugins": [ | ||
"preset-github" | ||
] | ||
}, | ||
@@ -109,3 +113,5 @@ "repository": { | ||
"extends": "prettier", | ||
"plugins": ["prettier"], | ||
"plugins": [ | ||
"prettier" | ||
], | ||
"parserOptions": { | ||
@@ -135,4 +141,6 @@ "sourceType": "script" | ||
"space": true, | ||
"ignore": ["config.js"] | ||
"ignore": [ | ||
"config.js" | ||
] | ||
} | ||
} |
@@ -89,3 +89,3 @@ <h1 align="center"> | ||
// `ctx.log('warn', 'Logged out')` | ||
// `ctx.logger.warn` | ||
// `ctx.logger.warn('Logged out')` | ||
// `ctx.logger('warn', 'Logged out')` | ||
@@ -136,3 +136,3 @@ | ||
* `logger` (Object) - defaults to `console` (you might want to use something like [Lad's logger][lad-logger]) | ||
* `userFields` (Array) - defaults to `[ 'id', 'email', 'full_namel']` - these are the default fields to store from a parsed user object | ||
* `userFields` (Array) - defaults to `[ 'id', 'email', 'full_name']` - these are the default fields to store from a parsed user object | ||
@@ -157,2 +157,3 @@ | ||
* [lass][] - Scaffold a modern boilerplate for [Node.js][node] | ||
* [lipo][] - Free image manipulation API service built on top of [Sharp][] | ||
@@ -169,3 +170,3 @@ | ||
Lad, Lass, Cabin, and their respective logos are trademarks of Niftylettuce LLC. | ||
Lad, Lass, Cabin, Lipo, and their respective logos are trademarks of Niftylettuce LLC. | ||
These trademarks may not be reproduced, distributed, transmitted, or otherwise used, except with the prior written permission of Niftylettuce LLC. | ||
@@ -203,1 +204,5 @@ If you are seeking permission to use these trademarks, then please [contact us](mailto:niftylettuce@gmail.com). | ||
[fast-safe-stringify]: https://github.com/davidmarkclements/fast-safe-stringify | ||
[sharp]: http://sharp.dimens.io/ | ||
[lipo]: https://lipo.io |
@@ -5,3 +5,3 @@ const test = require('ava'); | ||
const Cabin = require('../'); | ||
const Cabin = require('..'); | ||
@@ -8,0 +8,0 @@ test.cb.beforeEach(t => { |
@@ -5,3 +5,3 @@ const test = require('ava'); | ||
const Cabin = require('../'); | ||
const Cabin = require('..'); | ||
@@ -8,0 +8,0 @@ test.cb.beforeEach(t => { |
const test = require('ava'); | ||
const Cabin = require('../'); | ||
const Cabin = require('..'); | ||
@@ -5,0 +5,0 @@ test.beforeEach(t => { |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
285229
16
204
0
4
15
216
+ Addedauto-bind@^1.2.0
+ Addedauto-bind@1.2.1(transitive)
+ Addedfast-safe-stringify@2.1.1(transitive)
- Removedfast-safe-stringify@1.2.3(transitive)
Updatedfast-safe-stringify@^2.0.4
Updatedlodash@^4.17.10