Skip to content

Commit 27e8575

Browse files
authored
chore(deps): update dependencies (#37)
* chore(deps): update dependencies * chore(lint): apply and adjust with new linting rules
1 parent e58bf16 commit 27e8575

File tree

4 files changed

+2196
-2693
lines changed

4 files changed

+2196
-2693
lines changed

lib/index.js

+17-11
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
const DogstatsdClient = require('dog-statsy');
22
const Hoek = require('@hapi/hoek');
33
const debug = require('debug')('hapi:plugins:dogstatsd');
4-
const { get, set, uniq, uniqWith, isEqual } = require('lodash');
4+
const {
5+
get, set, uniq, uniqWith, isEqual
6+
} = require('lodash');
57

68
const defaults = {
79
dogstatsdClient: null,
@@ -13,27 +15,27 @@ const defaults = {
1315
excludedTags: []
1416
};
1517

16-
const getRequestDns = request => request.headers.host.replace(/:/, '_');
18+
const getRequestDns = (request) => request.headers.host.replace(/:/, '_');
1719

18-
const getUrlPath = request => request.url.pathname;
20+
const getUrlPath = (request) => request.url.pathname;
1921

2022
const getRoutePath = (request) => {
21-
const specials = request._core.router.specials;
23+
const { specials } = request._core.router;
2224

2325
if (request._route === specials.notFound.route) {
2426
return '/{notFound*}';
25-
} else if (specials.options && request._route === specials.options.route) {
27+
} if (specials.options && request._route === specials.options.route) {
2628
return '/{cors*}';
27-
} else if (request._route.path === '/' && request._route.method === 'options') {
29+
} if (request._route.path === '/' && request._route.method === 'options') {
2830
return '/{cors*}';
2931
}
3032
return request.route.path;
3133
};
3234

33-
const getStatusCode = request => ((request.response.isBoom)
35+
const getStatusCode = (request) => ((request.response.isBoom)
3436
? request.response.output.statusCode : request.response.statusCode);
3537

36-
const getHttpMethod = request => request.method.toUpperCase();
38+
const getHttpMethod = (request) => request.method.toUpperCase();
3739

3840
const tagMap = {
3941
dns: getRequestDns,
@@ -58,7 +60,7 @@ exports.injectMetrics = ({ request, metrics }) => {
5860
exports.register = (server, options) => {
5961
const settings = Hoek.applyToDefaults(defaults, options || {});
6062
// Filter list of default tags, removing excludedTags
61-
settings.defaultTags = Object.keys(tagMap).filter(e => !settings.excludedTags.includes(e));
63+
settings.defaultTags = Object.keys(tagMap).filter((e) => !settings.excludedTags.includes(e));
6264

6365
const dogstatsdClient = options.dogstatsdClient || new DogstatsdClient({
6466
host: settings.host,
@@ -115,9 +117,13 @@ exports.register = (server, options) => {
115117
Hoek.merge(defaultMetrics, stateMetrics);
116118

117119
for (const metric of defaultMetrics) {
118-
const { type, name, value, tags = [] } = metric;
120+
const {
121+
type, name, value, tags = []
122+
} = metric;
119123
const combinedTags = [...localTags, ...tags];
120-
debug({ type, name, value, tags: combinedTags });
124+
debug({
125+
type, name, value, tags: combinedTags
126+
});
121127
dogstatsdClient[type](name, value, combinedTags);
122128
}
123129
});

package.json

+10-10
Original file line numberDiff line numberDiff line change
@@ -97,19 +97,19 @@
9797
]
9898
},
9999
"devDependencies": {
100-
"@hapi/hapi": "^18.3.1",
101-
"auto-changelog": "^1.1.0",
102-
"cross-env": "^5.0.5",
103-
"eslint": "^4.8.0",
104-
"eslint-config-goodway": "^1.3.0",
105-
"eslint-plugin-import": "^2.7.0",
106-
"jest": "^24.8.0",
100+
"@hapi/hapi": "^20.0.0",
101+
"auto-changelog": "^2.2.0",
102+
"cross-env": "^7.0.2",
103+
"eslint": "^7.7.0",
104+
"eslint-config-goodway": "^2.1.1",
105+
"eslint-plugin-import": "^2.22.0",
106+
"jest": "^26.4.0",
107107
"pre-push": "^0.1.1"
108108
},
109109
"dependencies": {
110-
"@hapi/hoek": "^8.2.0",
110+
"@hapi/hoek": "^9.0.4",
111111
"debug": "^4.1.1",
112-
"dog-statsy": "1.2.1",
113-
"lodash": "^4.17.15"
112+
"dog-statsy": "1.3.1",
113+
"lodash": "^4.17.20"
114114
}
115115
}

spec/hapi-dogstatsd.spec.js

+14-8
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
const assert = require('assert');
2-
const plugin = require('../lib');
32
const Hapi = require('@hapi/hapi');
3+
const plugin = require('../lib');
44

55
describe('lib-hapi-dogstatsd plugin tests', () => {
66
describe('general use case', () => {
@@ -43,15 +43,21 @@ describe('lib-hapi-dogstatsd plugin tests', () => {
4343
return 'Success!';
4444
};
4545

46-
server.route({ method: ['GET', 'OPTIONS'], path: '/', handler: get, config: { cors: true } });
47-
server.route({ method: 'GET', path: '/throwError', handler: err, config: { cors: true } });
46+
server.route({
47+
method: ['GET', 'OPTIONS'], path: '/', handler: get, config: { cors: true }
48+
});
49+
server.route({
50+
method: 'GET', path: '/throwError', handler: err, config: { cors: true }
51+
});
4852
server.route({ method: 'GET', path: '/test/withtags', handler: withTags });
4953
server.route({ method: 'GET', path: '/test/withmetrics', handler: withMetrics });
50-
server.route({ method: 'GET', path: '/test/{param}', handler: get, config: { cors: true } });
54+
server.route({
55+
method: 'GET', path: '/test/{param}', handler: get, config: { cors: true }
56+
});
5157
server.route({ method: 'GET', path: '/favicon.ico', handler: get });
5258
server.route({ method: 'GET', path: '/health-check', handler: get });
5359

54-
return await server.register({
60+
return server.register({
5561
plugin,
5662
options: { dogstatsdClient: mockStatsdClient }
5763
});
@@ -158,7 +164,7 @@ describe('lib-hapi-dogstatsd plugin tests', () => {
158164
port: 8085
159165
});
160166

161-
return await server.register({ plugin });
167+
return server.register({ plugin });
162168
});
163169

164170
it('should expose dogstatsd client to the hapi server', () => {
@@ -186,7 +192,7 @@ describe('lib-hapi-dogstatsd plugin tests', () => {
186192

187193
server.route({ method: 'GET', path: '/test', handler: get });
188194

189-
return await server.register({
195+
return server.register({
190196
plugin,
191197
options: {
192198
dogstatsdClient: mockStatsdClient,
@@ -212,7 +218,7 @@ describe('lib-hapi-dogstatsd plugin tests', () => {
212218
port: 8085
213219
});
214220

215-
return await server.register({
221+
return server.register({
216222
plugin,
217223
options: {
218224
tags: ['test:tag'],

0 commit comments

Comments
 (0)