fastify-graylog-reporter
Advanced tools
Comparing version 1.11.1 to 1.12.0
@@ -1,6 +0,6 @@ | ||
## [1.11.1](https://github.com/Blynskyniki/fastify-graylog-reporter/compare/v1.11.0...v1.11.1) (2023-10-12) | ||
# [1.12.0](https://github.com/Blynskyniki/fastify-graylog-reporter/compare/v1.11.1...v1.12.0) (2023-10-13) | ||
### Bug Fixes | ||
### Features | ||
* type credentials ([eae0352](https://github.com/Blynskyniki/fastify-graylog-reporter/commit/eae0352e1a32841ce59321d6645ca17a12a21522)) | ||
* option exclude fields for report ([396481e](https://github.com/Blynskyniki/fastify-graylog-reporter/commit/396481ecf507157267901212004347096ecdfa70)) |
@@ -8,2 +8,5 @@ /// <reference types="node" /> | ||
} | ||
export declare const fastifyGrayLogReporter: FastifyPluginCallback<Omit<import("./Gelf").ConnectionOptions, "minCompressSize" | "maxChunkSize"> & Partial<Pick<import("./Gelf").ConnectionOptions, "minCompressSize" | "maxChunkSize">>, import("http").Server, import("fastify").FastifyTypeProviderDefault, import("fastify").FastifyBaseLogger>; | ||
export type ExcludeKeys = 'query' | 'params' | 'body' | 'response' | 'credentials' | 'responseStatusCode' | 'requestHeaders' | 'responseHeaders'; | ||
export declare const fastifyGrayLogReporter: FastifyPluginCallback<Omit<import("./Gelf").ConnectionOptions, "minCompressSize" | "maxChunkSize"> & Partial<Pick<import("./Gelf").ConnectionOptions, "minCompressSize" | "maxChunkSize">> & { | ||
excludeFields?: ExcludeKeys[] | undefined; | ||
}, import("http").Server, import("fastify").FastifyTypeProviderDefault, import("fastify").FastifyBaseLogger>; |
@@ -12,6 +12,6 @@ "use strict"; | ||
fastify.addHook('onSend', async (request, reply, response) => { | ||
var _a; | ||
var _a, _b; | ||
const { query, params, body, headers, routerMethod, routerPath, credentials } = request; | ||
try { | ||
await instance.report({ | ||
const data = { | ||
host: (headers === null || headers === void 0 ? void 0 : headers['host']) || ((_a = headers === null || headers === void 0 ? void 0 : headers['x-forwarded-for']) === null || _a === void 0 ? void 0 : _a[0]) || 'empty', | ||
@@ -28,4 +28,12 @@ short_message: `${routerMethod}:${routerPath} ${params ? 'params:' + JSON.stringify(params) : ''}${query ? 'query:' + JSON.stringify(query) : ''}${body ? 'body:' + JSON.stringify(body) : ''}`, | ||
credentials, | ||
headers, | ||
}); | ||
responseStatusCode: reply.statusCode, | ||
requestHeaders: headers, | ||
responseHeaders: reply.getHeaders(), | ||
}; | ||
if (options.excludeFields) { | ||
(_b = options.excludeFields) === null || _b === void 0 ? void 0 : _b.forEach(key => { | ||
delete data[key]; | ||
}); | ||
} | ||
await instance.report(data); | ||
} | ||
@@ -32,0 +40,0 @@ catch (err) { |
{ | ||
"name": "fastify-graylog-reporter", | ||
"version": "1.11.1", | ||
"version": "1.12.0", | ||
"description": "Fastify plugin for report request data to Graylog", | ||
@@ -5,0 +5,0 @@ "homepage": "https://github.com/Blynskyniki/fastify-graylog-reporter#readme", |
@@ -29,2 +29,12 @@ # Fastify plugin for report request data to Graylog (GELF) | ||
facility: `API_${process.env.ENVIRONMENT}`, | ||
/** | ||
* keys for exclude report (type ExcludeKeys[]) | ||
*/ | ||
excludeFields: [], | ||
/** | ||
* For debug | ||
*/ | ||
logs: true, | ||
}); | ||
@@ -31,0 +41,0 @@ |
Sorry, the diff of this file is not supported yet
145681
312
61