fastify-graylog-reporter
Advanced tools
Comparing version 1.0.0 to 1.1.0
@@ -1,14 +0,7 @@ | ||
# 1.0.0 (2023-10-11) | ||
# [1.1.0](https://github.com/Blynskyniki/fastify-graylog-reporter/compare/v1.0.0...v1.1.0) (2023-10-12) | ||
### Bug Fixes | ||
* fix build ([a634495](https://github.com/Blynskyniki/fastify-graylog-reporter/commit/a6344951e5638ee47b4e2a67866c55220d00d94f)) | ||
### Features | ||
* add repository block in package json ([bf04b98](https://github.com/Blynskyniki/fastify-graylog-reporter/commit/bf04b98020ddb7f338af5b8235fad4476ee72bca)) | ||
* add repository block in package json ([9e7f130](https://github.com/Blynskyniki/fastify-graylog-reporter/commit/9e7f13000fdd1a4f532f347433679df7e09d0596)) | ||
* clear ([ef02e18](https://github.com/Blynskyniki/fastify-graylog-reporter/commit/ef02e186a7bd294e4945d0e59e5aca673218179c)) | ||
* initial ([dcceb86](https://github.com/Blynskyniki/fastify-graylog-reporter/commit/dcceb868abe080c6a7d91956cbe55b28dae154d2)) | ||
* исправления ([ab31ca5](https://github.com/Blynskyniki/fastify-graylog-reporter/commit/ab31ca58ebe7a173821c3e853374cbb332a6276d)) | ||
* исправления ([3c08820](https://github.com/Blynskyniki/fastify-graylog-reporter/commit/3c088200ba6a849ad25367a970a474d014a0f897)) |
@@ -40,3 +40,2 @@ "use strict"; | ||
} | ||
console.info('UDP message sent'); | ||
client.close(); | ||
@@ -47,3 +46,3 @@ }); | ||
sendMessage(msg) { | ||
this.send(Buffer.from(JSON.stringify(msg), 'utf8')); | ||
this.send(Buffer.from(JSON.stringify(msg.toJSON()), 'utf8')); | ||
} | ||
@@ -50,0 +49,0 @@ } |
@@ -11,8 +11,7 @@ export interface AxiosErrorLike<T = any> extends Error { | ||
private readonly facility; | ||
private readonly headers; | ||
private readonly message; | ||
private readonly timestamp; | ||
private location?; | ||
constructor(facility: string, headers: any, message: string, timestamp: number, location?: string | undefined); | ||
static from(error: AxiosErrorLike): GelfMessage; | ||
constructor(facility: string, message: Record<string, any>, timestamp: number, location?: string | undefined); | ||
static from(error: AxiosErrorLike, facility?: string): GelfMessage; | ||
static fromJSON(facility: string, data: object): GelfMessage; | ||
@@ -22,4 +21,3 @@ setLocation(location: string): this; | ||
facility: string; | ||
headers: any; | ||
message: string; | ||
message: Record<string, any>; | ||
timestamp: number; | ||
@@ -26,0 +24,0 @@ location: string | undefined; |
@@ -5,5 +5,4 @@ "use strict"; | ||
class GelfMessage { | ||
constructor(facility, headers, message, timestamp, location) { | ||
constructor(facility, message, timestamp, location) { | ||
this.facility = facility; | ||
this.headers = headers; | ||
this.message = message; | ||
@@ -13,8 +12,8 @@ this.timestamp = timestamp; | ||
} | ||
static from(error) { | ||
var _a, _b; | ||
return new GelfMessage(process.env.SERVICE_NAME || 'unknown', (_a = error.config) === null || _a === void 0 ? void 0 : _a.headers, JSON.stringify((_b = error.response) === null || _b === void 0 ? void 0 : _b.data), Date.now() / 1000); | ||
static from(error, facility = 'unknown') { | ||
var _a; | ||
return new GelfMessage(facility, ((_a = error.response) === null || _a === void 0 ? void 0 : _a.data) || {}, Date.now() / 1000); | ||
} | ||
static fromJSON(facility, data) { | ||
return new GelfMessage(facility, {}, JSON.stringify(data), Date.now() / 1000); | ||
return new GelfMessage(facility, data, Date.now() / 1000); | ||
} | ||
@@ -28,3 +27,2 @@ setLocation(location) { | ||
facility: this.facility, | ||
headers: this.headers, | ||
message: this.message, | ||
@@ -31,0 +29,0 @@ timestamp: this.timestamp, |
@@ -13,7 +13,4 @@ "use strict"; | ||
fastify.addHook('onResponse', (request, reply, done) => { | ||
const { query, params, body, headers, method, routerPath } = request; | ||
const payload = { | ||
request: { query, params, body, headers }, | ||
}; | ||
instance.sendMessage(Gelf_1.GelfMessage.fromJSON(facility, payload)); | ||
const { query, params, body, headers, routerMethod, routerPath } = request; | ||
instance.sendMessage(Gelf_1.GelfMessage.fromJSON(facility, { path: routerPath, method: routerMethod, query, params, body, headers })); | ||
done(); | ||
@@ -20,0 +17,0 @@ }); |
{ | ||
"name": "fastify-graylog-reporter", | ||
"version": "1.0.0", | ||
"version": "1.1.0", | ||
"description": "Fastify plugin for report request data to Graylog", | ||
@@ -40,3 +40,16 @@ "homepage": "https://github.com/Blynskyniki/fastify-graylog-reporter#readme", | ||
}, | ||
"bugs": { | ||
"url": "https://github.com/Blynskyniki/fastify-graylog-reporter/issues" | ||
}, | ||
"author": "BlynskyNiki <blynskyniki@gmail.com>", | ||
"contributors": [ | ||
{ | ||
"name": "Blynskyniki", | ||
"url": "https://github.com/Blynskyniki" | ||
}, | ||
{ | ||
"name": "Alexandrmrk", | ||
"url": "https://github.com/Alexandrmrk" | ||
} | ||
], | ||
"license": "MIT", | ||
@@ -43,0 +56,0 @@ "dependencies": { |
@@ -1,2 +0,2 @@ | ||
# Fastify plugin for report request data to Graylog | ||
# Fastify plugin for report request data to Graylog (GELF) | ||
@@ -6,6 +6,9 @@ ![npm](https://img.shields.io/npm/dw/fastify-graylog-reporter) | ||
[![NPM](https://nodei.co/npm/fastify-graylog-reporter.png)](https://nodei.co/npm/fastify-graylog-reporter/) | ||
## Install | ||
## Usage | ||
1. Declare the input on Graylog WEB UI (support only UDP GELF) | ||
2. Install plugin with ```npm i fastify-graylog-reporter``` | ||
3. Use. | ||
```typescript | ||
import { fastifyGrayLogReporter } from 'fastifyGrayLogReporter'; | ||
import { fastifyGrayLogReporter } from 'fastify-graylog-reporter'; | ||
/** | ||
@@ -12,0 +15,0 @@ * Register plugin |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
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
No bug tracker
MaintenancePackage does not have a linked bug tracker in package.json.
Found 1 instance in 1 package
0
32
11292
15
157