@ogcio/fastify-logging-wrapper 5.0.2 → 5.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,5 +1,5 @@
1
- import test from 'node:test';
2
- import assert from 'node:assert/strict';
1
+ import { httpErrors } from "@fastify/sensible";
2
+ import { assert, afterEach, describe, it } from "vitest";
3
3
  import { LogErrorClasses } from "../src/logging-wrapper-entities.js";
4
4
  import {
5
5
  DEFAULT_METHOD,
@@ -11,117 +11,128 @@ import {
11
11
  parseLogEntry,
12
12
  runErrorTest,
13
13
  } from "./helpers/fastify-test-helpers.js";
14
- import { httpErrors } from '@fastify/sensible';
15
14
 
16
- test("Error data are correctly set", async (t) => {
17
- const { server, loggingDestination } = initializeServer();
18
- t.after(() => server.close());
19
- await runErrorTest({
20
- server,
21
- loggingDestination,
22
- inputStatusCode: "500",
23
- expectedStatusCode: 500,
24
- errorMessage: "WHoooopS!",
25
- expectedClass: LogErrorClasses.ServerError,
15
+ describe("Error data are correctly set", () => {
16
+ it("should pass", async () => {
17
+ const { server, loggingDestination } = initializeServer();
18
+ afterEach(() => server.close());
19
+ await runErrorTest({
20
+ server,
21
+ loggingDestination,
22
+ inputStatusCode: "500",
23
+ expectedStatusCode: 500,
24
+ errorMessage: "WHoooopS!",
25
+ expectedClass: LogErrorClasses.ServerError,
26
+ });
26
27
  });
27
28
  });
28
29
 
29
- test("Unknown Error route logs expected values", async (t) => {
30
- const { server, loggingDestination } = initializeServer();
31
- t.after(() => server.close());
32
- await runErrorTest({
33
- server,
34
- loggingDestination,
35
- inputStatusCode: "399",
36
- expectedStatusCode: 500,
37
- errorMessage: "Unknown!",
38
- expectedClass: LogErrorClasses.UnknownError,
30
+ describe("Unknown Error route logs expected values", () => {
31
+ it("should pass", async () => {
32
+ const { server, loggingDestination } = initializeServer();
33
+ afterEach(() => server.close());
34
+ await runErrorTest({
35
+ server,
36
+ loggingDestination,
37
+ inputStatusCode: "399",
38
+ expectedStatusCode: 500,
39
+ errorMessage: "Unknown!",
40
+ expectedClass: LogErrorClasses.UnknownError,
41
+ });
39
42
  });
40
43
  });
41
44
 
42
- test("400 Error route logs expected values", async (t) => {
43
- const { server, loggingDestination } = initializeServer();
44
- t.after(() => server.close());
45
- await runErrorTest({
46
- server,
47
- loggingDestination,
48
- inputStatusCode: "400",
49
- expectedStatusCode: 400,
50
- errorMessage: "Bad request!",
51
- expectedClass: LogErrorClasses.RequestError,
45
+ describe("400 Error route logs expected values", () => {
46
+ it("should pass", async () => {
47
+ const { server, loggingDestination } = initializeServer();
48
+ afterEach(() => server.close());
49
+ await runErrorTest({
50
+ server,
51
+ loggingDestination,
52
+ inputStatusCode: "400",
53
+ expectedStatusCode: 400,
54
+ errorMessage: "Bad request!",
55
+ expectedClass: LogErrorClasses.RequestError,
56
+ });
52
57
  });
53
58
  });
54
59
 
55
- test("422 Validation Error route logs expected values", async (t) => {
56
- const { server, loggingDestination } = initializeServer();
57
- t.after(() => server.close());
58
- await runErrorTest({
59
- server,
60
- loggingDestination,
61
- inputStatusCode: "422",
62
- expectedStatusCode: 422,
63
- errorMessage: "Bad request!",
64
- expectedClass: LogErrorClasses.ValidationError,
60
+ describe("422 Validation Error route logs expected values", () => {
61
+ it("should pass", async () => {
62
+ const { server, loggingDestination } = initializeServer();
63
+ afterEach(() => server.close());
64
+ await runErrorTest({
65
+ server,
66
+ loggingDestination,
67
+ inputStatusCode: "422",
68
+ expectedStatusCode: 422,
69
+ errorMessage: "Bad request!",
70
+ expectedClass: LogErrorClasses.ValidationError,
71
+ });
65
72
  });
66
73
  });
67
74
 
68
- test("Error without status code logs expected values", async (t) => {
69
- const { server, loggingDestination } = initializeServer();
70
- t.after(() => server.close());
71
- await runErrorTest({
72
- server,
73
- loggingDestination,
74
- inputStatusCode: undefined,
75
- expectedStatusCode: 500,
76
- errorMessage: "Unknown!",
77
- expectedClass: LogErrorClasses.UnknownError,
78
- expectedFastifyCode: "UNHANDLED_EXCEPTION",
75
+ describe("Error without status code logs expected values", () => {
76
+ it("should pass", async () => {
77
+ const { server, loggingDestination } = initializeServer();
78
+ afterEach(() => server.close());
79
+ await runErrorTest({
80
+ server,
81
+ loggingDestination,
82
+ inputStatusCode: undefined,
83
+ expectedStatusCode: 500,
84
+ errorMessage: "Unknown!",
85
+ expectedClass: LogErrorClasses.UnknownError,
86
+ expectedFastifyCode: "UNHANDLED_EXCEPTION",
87
+ });
79
88
  });
80
89
  });
81
90
 
82
- test("Life events error logs expected values", async (t) => {
83
- const { server, loggingDestination } = initializeServer();
84
- t.after(() => server.close());
85
- const response = await server.inject({
86
- method: DEFAULT_METHOD,
87
- url: "/life-events-error",
88
- });
91
+ describe("Life events error logs expected values", () => {
92
+ it("should pass", async () => {
93
+ const { server, loggingDestination } = initializeServer();
94
+ afterEach(() => server.close());
95
+ const response = await server.inject({
96
+ method: DEFAULT_METHOD,
97
+ url: "/life-events-error",
98
+ });
89
99
 
90
- assert.ok(typeof response !== "undefined");
91
- assert.equal(response.statusCode, 500);
92
- const loggedRecords = loggingDestination.getLoggedRecords();
93
- assert.equal(loggedRecords.length, 4);
94
- const mockErrorInstance = httpErrors.createError("mock");
95
- checkExpectedRequestEntry({
96
- requestLogEntry: loggedRecords[0],
97
- inputPath: "/life-events-error",
98
- });
100
+ assert.ok(typeof response !== "undefined");
101
+ assert.equal(response.statusCode, 500);
102
+ const loggedRecords = loggingDestination.getLoggedRecords();
103
+ assert.equal(loggedRecords.length, 4);
104
+ const mockErrorInstance = httpErrors.createError("mock");
105
+ checkExpectedRequestEntry({
106
+ requestLogEntry: loggedRecords[0],
107
+ inputPath: "/life-events-error",
108
+ });
99
109
 
100
- checkExpectedErrorEntry({
101
- errorLogEntry: loggedRecords[1],
102
- inputPath: "/life-events-error",
103
- errorClass: LogErrorClasses.ServerError,
104
- errorMessage: "mock",
105
- errorCode: mockErrorInstance.name,
106
- expectedLevelName: "ERROR",
107
- });
108
- const parsed = parseLogEntry(loggedRecords[1]);
109
- assert.equal(parsed.error.process, "TESTING");
110
- assert.equal(parsed.error.parent.message, "I am the parent");
111
- assert.equal(parsed.error.parent.name, "Error");
112
- assert.equal(typeof parsed.error.parent.stack, "string");
110
+ checkExpectedErrorEntry({
111
+ errorLogEntry: loggedRecords[1],
112
+ inputPath: "/life-events-error",
113
+ errorClass: LogErrorClasses.ServerError,
114
+ errorMessage: "mock",
115
+ errorCode: mockErrorInstance.name,
116
+ expectedLevelName: "ERROR",
117
+ });
118
+ const parsed = parseLogEntry(loggedRecords[1]);
119
+ assert.equal(parsed.error.process, "TESTING");
120
+ assert.equal(parsed.error.parent.message, "I am the parent");
121
+ assert.equal(parsed.error.parent.name, "Error");
122
+ assert.equal(typeof parsed.error.parent.stack, "string");
113
123
 
114
- checkExpectedResponseEntry({
115
- responseLogEntry: loggedRecords[2],
116
- inputPath: "/life-events-error",
117
- responseStatusCode: 500,
118
- });
119
- checkExpectedApiTrackEntry({
120
- apiTrackLogEntry: loggedRecords[3],
121
- inputPath: "/life-events-error",
122
- responseStatusCode: 500,
123
- errorClass: LogErrorClasses.ServerError,
124
- errorMessage: "mock",
125
- errorCode: mockErrorInstance.name,
124
+ checkExpectedResponseEntry({
125
+ responseLogEntry: loggedRecords[2],
126
+ inputPath: "/life-events-error",
127
+ responseStatusCode: 500,
128
+ });
129
+ checkExpectedApiTrackEntry({
130
+ apiTrackLogEntry: loggedRecords[3],
131
+ inputPath: "/life-events-error",
132
+ responseStatusCode: 500,
133
+ errorClass: LogErrorClasses.ServerError,
134
+ errorMessage: "mock",
135
+ errorCode: mockErrorInstance.name,
136
+ });
126
137
  });
127
138
  });
@@ -1,106 +1,121 @@
1
- import { LogMessages } from "../src/logging-wrapper-entities.js";
2
- import { initializeServer, DEFAULT_METHOD, DEFAULT_PATH, checkExpectedRequestEntry, checkExpectedResponseEntry, parseLogEntry, checkGenericEntryFields } from "./helpers/fastify-test-helpers.js";
3
1
  import { REQUEST_ID_HEADER } from "@ogcio/shared-errors";
4
- import assert from "node:assert";
5
- import { test } from 'node:test';
2
+ import { assert, afterEach, describe, it } from "vitest";
3
+ import { LogMessages } from "../src/logging-wrapper-entities.js";
4
+ import {
5
+ DEFAULT_METHOD,
6
+ DEFAULT_PATH,
7
+ checkExpectedRequestEntry,
8
+ checkExpectedResponseEntry,
9
+ checkGenericEntryFields,
10
+ initializeServer,
11
+ parseLogEntry,
12
+ } from "./helpers/fastify-test-helpers.js";
6
13
 
7
- test("Logging entries when all works fine are the expected ones", async (t) => {
8
- const { server, loggingDestination } = initializeServer();
9
- t.after(() => server.close());
14
+ describe("Logging entries when all works fine are the expected ones", () => {
15
+ it("should pass", async () => {
16
+ const { server, loggingDestination } = initializeServer();
17
+ afterEach(() => server.close());
10
18
 
11
- const response = await server.inject({
12
- method: DEFAULT_METHOD,
13
- url: DEFAULT_PATH,
14
- });
15
- assert.ok(typeof response !== "undefined");
16
- assert.equal(response?.statusCode, 200);
17
- const loggedRecords = loggingDestination.getLoggedRecords();
18
- assert.equal(loggedRecords.length, 3);
19
- checkExpectedRequestEntry({
20
- requestLogEntry: loggedRecords[0],
21
- });
22
- checkExpectedResponseEntry({
23
- responseLogEntry: loggedRecords[1],
24
- responseStatusCode: 200,
25
- });
26
- checkExpectedResponseEntry({
27
- responseLogEntry: loggedRecords[2],
28
- responseStatusCode: 200,
29
- expectedMessage: LogMessages.ApiTrack,
19
+ const response = await server.inject({
20
+ method: DEFAULT_METHOD,
21
+ url: DEFAULT_PATH,
22
+ });
23
+ assert.ok(typeof response !== "undefined");
24
+ assert.equal(response?.statusCode, 200);
25
+ const loggedRecords = loggingDestination.getLoggedRecords();
26
+ assert.equal(loggedRecords.length, 3);
27
+ checkExpectedRequestEntry({
28
+ requestLogEntry: loggedRecords[0],
29
+ });
30
+ checkExpectedResponseEntry({
31
+ responseLogEntry: loggedRecords[1],
32
+ responseStatusCode: 200,
33
+ });
34
+ checkExpectedResponseEntry({
35
+ responseLogEntry: loggedRecords[2],
36
+ responseStatusCode: 200,
37
+ expectedMessage: LogMessages.ApiTrack,
38
+ });
30
39
  });
31
40
  });
32
41
 
33
- test("Request id is overriden by header", async (t) => {
34
- const { server, loggingDestination } = initializeServer();
35
- t.after(() => server.close());
36
- const customRequestId = "Another request id";
37
- const response = await server.inject({
38
- method: DEFAULT_METHOD,
39
- url: DEFAULT_PATH,
40
- headers: { [REQUEST_ID_HEADER]: customRequestId },
41
- });
42
- assert.ok(typeof response !== "undefined");
43
- assert.equal(response?.statusCode, 200);
44
- const logged = loggingDestination.getLoggedRecords();
45
- checkExpectedRequestEntry({
46
- requestLogEntry: logged[0],
47
- inputHeaders: { [REQUEST_ID_HEADER]: customRequestId },
42
+ describe("Request id is overriden by header", () => {
43
+ it("should pass", async () => {
44
+ const { server, loggingDestination } = initializeServer();
45
+ afterEach(() => server.close());
46
+ const customRequestId = "Another request id";
47
+ const response = await server.inject({
48
+ method: DEFAULT_METHOD,
49
+ url: DEFAULT_PATH,
50
+ headers: { [REQUEST_ID_HEADER]: customRequestId },
51
+ });
52
+ assert.ok(typeof response !== "undefined");
53
+ assert.equal(response?.statusCode, 200);
54
+ const logged = loggingDestination.getLoggedRecords();
55
+ checkExpectedRequestEntry({
56
+ requestLogEntry: logged[0],
57
+ inputHeaders: { [REQUEST_ID_HEADER]: customRequestId },
58
+ });
59
+ const parsedEntry = parseLogEntry(logged[0]);
60
+ assert.deepEqual(parsedEntry.request_id, customRequestId);
48
61
  });
49
- const parsedEntry = parseLogEntry(logged[0]);
50
- assert.deepEqual(parsedEntry.request_id, customRequestId);
51
62
  });
52
63
 
53
- test("Logging context is reset between requests", async (t) => {
54
- const { server, loggingDestination } = initializeServer();
55
- t.after(() => server.close());
64
+ describe("Logging context is reset between requests", () => {
65
+ it("should pass", async () => {
66
+ const { server, loggingDestination } = initializeServer();
67
+ afterEach(() => server.close());
56
68
 
57
- let response = await server.inject({
58
- method: DEFAULT_METHOD,
59
- url: DEFAULT_PATH,
60
- });
69
+ let response = await server.inject({
70
+ method: DEFAULT_METHOD,
71
+ url: DEFAULT_PATH,
72
+ });
61
73
 
62
- assert.ok(typeof response !== "undefined");
63
- assert.equal(response?.statusCode, 200);
64
- let loggedRecords = loggingDestination.getLoggedRecords();
65
- assert.equal(loggedRecords.length, 3);
66
- let parsedResponse = parseLogEntry(loggedRecords[1]);
67
- assert.ok(typeof parsedResponse.response !== "undefined");
74
+ assert.ok(typeof response !== "undefined");
75
+ assert.equal(response?.statusCode, 200);
76
+ let loggedRecords = loggingDestination.getLoggedRecords();
77
+ assert.equal(loggedRecords.length, 3);
78
+ let parsedResponse = parseLogEntry(loggedRecords[1]);
79
+ assert.ok(typeof parsedResponse.response !== "undefined");
68
80
 
69
- response = await server.inject({
70
- method: DEFAULT_METHOD,
71
- url: DEFAULT_PATH,
81
+ response = await server.inject({
82
+ method: DEFAULT_METHOD,
83
+ url: DEFAULT_PATH,
84
+ });
85
+ assert.ok(typeof response !== "undefined");
86
+ assert.equal(response?.statusCode, 200);
87
+ loggedRecords = loggingDestination.getLoggedRecords();
88
+ assert.equal(loggedRecords.length, 6);
89
+ // 3 is the New Request for 2nd call
90
+ parsedResponse = parseLogEntry(loggedRecords[3]);
91
+ // if undefined it means that the logging context
92
+ // has been reset between requests
93
+ assert.ok(typeof parsedResponse.response === "undefined");
72
94
  });
73
- assert.ok(typeof response !== "undefined");
74
- assert.equal(response?.statusCode, 200);
75
- loggedRecords = loggingDestination.getLoggedRecords();
76
- assert.equal(loggedRecords.length, 6);
77
- // 3 is the New Request for 2nd call
78
- parsedResponse = parseLogEntry(loggedRecords[3]);
79
- // if undefined it means that the logging context
80
- // has been reset between requests
81
- assert.ok(typeof parsedResponse.response === "undefined");
82
95
  });
83
96
 
84
- test("Additional logs are correctly written", async (t) => {
85
- const { server, loggingDestination } = initializeServer();
86
- t.after(() => server.close());
87
- const logMessage = "Testing additional logs";
97
+ describe("Additional logs are correctly written", () => {
98
+ it("should pass", async () => {
99
+ const { server, loggingDestination } = initializeServer();
100
+ afterEach(() => server.close());
101
+ const logMessage = "Testing additional logs";
88
102
 
89
- const response = await server.inject({
90
- method: "POST",
91
- url: "/logs",
92
- body: { log_entry: logMessage },
93
- });
103
+ const response = await server.inject({
104
+ method: "POST",
105
+ url: "/logs",
106
+ body: { log_entry: logMessage },
107
+ });
94
108
 
95
- assert.ok(typeof response !== "undefined");
96
- assert.equal(response?.statusCode, 200);
97
- const loggedRecords = loggingDestination.getLoggedRecords();
98
- assert.equal(loggedRecords.length, 4);
99
- const parsedAdditional = parseLogEntry(loggedRecords[1]);
100
- checkGenericEntryFields({
101
- parsedEntry: parsedAdditional,
102
- expectedLevelName: "INFO",
103
- expectedMessage: logMessage,
109
+ assert.ok(typeof response !== "undefined");
110
+ assert.equal(response?.statusCode, 200);
111
+ const loggedRecords = loggingDestination.getLoggedRecords();
112
+ assert.equal(loggedRecords.length, 4);
113
+ const parsedAdditional = parseLogEntry(loggedRecords[1]);
114
+ checkGenericEntryFields({
115
+ parsedEntry: parsedAdditional,
116
+ expectedLevelName: "INFO",
117
+ expectedMessage: logMessage,
118
+ });
119
+ assert.ok(typeof parsedAdditional.request !== "undefined");
104
120
  });
105
- assert.ok(typeof parsedAdditional.request !== "undefined");
106
121
  });
@@ -1,15 +1,17 @@
1
+ import { createError } from "@fastify/error";
2
+ import { httpErrors } from "@fastify/sensible";
1
3
  import Fastify from "fastify";
4
+ import type { DestinationStream } from "pino";
2
5
  import {
3
6
  getLoggingConfiguration,
4
7
  initializeLoggingHooks,
5
8
  } from "../../src/fastify-logging-wrapper.js";
6
- import { DestinationStream } from "pino";
7
- import { createError } from "@fastify/error";
8
- import { httpErrors } from "@fastify/sensible";
9
9
 
10
10
  export const buildFastify = (loggerDestination?: DestinationStream) => {
11
11
  const server = Fastify({
12
- ...getLoggingConfiguration(loggerDestination),
12
+ ...getLoggingConfiguration({
13
+ loggerDestination: loggerDestination,
14
+ }),
13
15
  });
14
16
 
15
17
  initializeLoggingHooks(server);
@@ -20,17 +22,17 @@ export const buildFastify = (loggerDestination?: DestinationStream) => {
20
22
 
21
23
  server.get("/error", async (request, _reply) => {
22
24
  const parsed = request.query as { [x: string]: unknown };
23
- const requestedStatusCode = Number(parsed["status_code"] ?? "500");
24
- const requestedMessage = String(parsed["error_message"] ?? "WHOOOPS");
25
+ const requestedStatusCode = Number(parsed.status_code ?? "500");
26
+ const requestedMessage = String(parsed.error_message ?? "WHOOOPS");
25
27
 
26
- if (!parsed["status_code"]) {
28
+ if (!parsed.status_code) {
27
29
  throw new Error(requestedMessage);
28
30
  }
29
31
 
30
32
  throw createError(
31
33
  "CUSTOM_CODE",
32
34
  requestedMessage as string,
33
- requestedStatusCode as number
35
+ requestedStatusCode as number,
34
36
  )();
35
37
  });
36
38
 
@@ -1,4 +1,4 @@
1
- import { PinoLoggerOptions } from "fastify/types/logger.js";
1
+ import type { PinoLoggerOptions } from "fastify/types/logger.js";
2
2
  import { pino } from "pino";
3
3
 
4
4
  export const buildLogger = (loggerConfiguration: PinoLoggerOptions) => {
@@ -1,14 +1,14 @@
1
- import { FastifyInstance } from "fastify";
1
+ import type { FastifyInstance } from "fastify";
2
+ import { assert } from "vitest";
3
+ import {
4
+ type LogErrorClasses,
5
+ LogMessages,
6
+ } from "../../src/logging-wrapper-entities.js";
2
7
  import { buildFastify } from "./build-fastify.js";
3
8
  import {
4
- TestingLoggerDestination,
9
+ type TestingLoggerDestination,
5
10
  getTestingDestinationLogger,
6
11
  } from "./build-logger.js";
7
- import {
8
- LogErrorClasses,
9
- LogMessages,
10
- } from "../../src/logging-wrapper-entities.js";
11
- import assert from 'node:assert/strict';
12
12
 
13
13
  export const DEFAULT_HOSTNAME = "localhost";
14
14
  export const DEFAULT_PORT = 80;
@@ -33,7 +33,8 @@ export const initializeServer = (): {
33
33
  return { server, loggingDestination };
34
34
  };
35
35
 
36
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
36
+ // biome-ignore lint/suspicious/noExplicitAny: <explanation>
37
+ // biome-ignore lint/suspicious/noExplicitAny: <explanation>
37
38
  export const parseLogEntry = (logEntry: string): { [x: string]: any } =>
38
39
  JSON.parse(logEntry);
39
40
 
@@ -77,7 +78,14 @@ export const checkExpectedRequestEntry = (params: {
77
78
  assert.equal(parsed.request?.path, params.inputPath);
78
79
  assert.equal(parsed.request?.hostname, DEFAULT_HOSTNAME);
79
80
  assert.equal(parsed.request?.port, DEFAULT_PORT);
80
- assert.deepStrictEqual(parsed.request?.query_params, params.inputQueryParams ?? {});
81
+ assert.deepStrictEqual(
82
+ parsed.request?.query_params,
83
+ params.inputQueryParams ?? {},
84
+ );
85
+ assert.deepStrictEqual(
86
+ parsed.request?.query_params,
87
+ params.inputQueryParams ?? {},
88
+ );
81
89
  assert.deepStrictEqual(parsed.request?.headers, {
82
90
  ...DEFAULT_REQUEST_HEADERS,
83
91
  ...(params.inputHeaders ?? {}),
@@ -111,7 +119,14 @@ export const checkExpectedResponseEntry = (params: {
111
119
  assert.equal(parsed.request.path, params.inputPath);
112
120
  assert.equal(parsed.request.hostname, DEFAULT_HOSTNAME);
113
121
  assert.equal(parsed.request.port, DEFAULT_PORT);
114
- assert.deepStrictEqual(parsed.request.query_params, params.inputQueryParams ?? {});
122
+ assert.deepStrictEqual(
123
+ parsed.request.query_params,
124
+ params.inputQueryParams ?? {},
125
+ );
126
+ assert.deepStrictEqual(
127
+ parsed.request.query_params,
128
+ params.inputQueryParams ?? {},
129
+ );
115
130
  assert.ok(typeof parsed.response !== "undefined");
116
131
  assert.equal(parsed.response.status_code, params.responseStatusCode);
117
132
  assert.equal(parsed.response.headers["content-type"], DEFAULT_CONTENT_TYPE);
@@ -177,7 +192,14 @@ export const checkExpectedErrorEntry = (params: {
177
192
  assert.equal(parsed.request?.path, params.inputPath);
178
193
  assert.equal(parsed.request?.hostname, DEFAULT_HOSTNAME);
179
194
  assert.equal(parsed.request?.port, DEFAULT_PORT);
180
- assert.deepStrictEqual(parsed.request?.query_params, params.inputQueryParams ?? {});
195
+ assert.deepStrictEqual(
196
+ parsed.request?.query_params,
197
+ params.inputQueryParams ?? {},
198
+ );
199
+ assert.deepStrictEqual(
200
+ parsed.request?.query_params,
201
+ params.inputQueryParams ?? {},
202
+ );
181
203
  assert.ok(typeof parsed.error !== "undefined");
182
204
  assert.equal(parsed.error.class, params.errorClass);
183
205
  assert.equal(parsed.error.code, params.errorCode);
@@ -1,10 +1,8 @@
1
- import { Level } from "pino";
2
- import { getLoggerConfiguration } from "../src/logging-wrapper.js";
3
- import { buildLogger } from "./helpers/build-logger.js";
4
1
  import { hostname } from "os";
2
+ import { assert, describe, it } from "vitest";
5
3
  import { REDACTED_VALUE } from "../src/logging-wrapper-entities.js";
6
- import assert from "node:assert";
7
- import { test } from "node:test";
4
+ import { getLoggerConfiguration } from "../src/logging-wrapper.js";
5
+ import { buildLogger } from "./helpers/build-logger.js";
8
6
 
9
7
  const getRandomFieldValue = () => Math.random().toString(36).slice(2);
10
8
 
@@ -106,63 +104,74 @@ const methodsDataProvider = [
106
104
  },
107
105
  ];
108
106
 
109
- test("Basic format is the expected one", async (t) => {
110
- const { logger, loggedRecordsMethod } = buildLogger({
111
- ...getLoggerConfiguration("debug"),
112
- });
113
- logger.debug("test message");
114
- logger.info("another message");
107
+ describe("Basic format is the expected one", () => {
108
+ it("should pass", async () => {
109
+ const { logger, loggedRecordsMethod } = buildLogger({
110
+ ...getLoggerConfiguration("debug"),
111
+ });
112
+ logger.debug("test message");
113
+ logger.info("another message");
115
114
 
116
- const loggedRecords = loggedRecordsMethod();
117
- assert.strictEqual(loggedRecords.length, 2);
115
+ const loggedRecords = loggedRecordsMethod();
116
+ assert.strictEqual(loggedRecords.length, 2);
118
117
 
119
- const parsed = JSON.parse(loggedRecords[0]);
120
- assert.strictEqual(typeof parsed.timestamp, "number");
121
- assert.ok(
122
- parsed.timestamp > Date.now() - 2000,
123
- "the timestamp must be newer than 2 seconds ago",
124
- );
125
- delete parsed.timestamp;
126
- assert.deepStrictEqual(parsed, {
127
- level: 20,
128
- level_name: "DEBUG",
129
- hostname: hostname(),
130
- message: "test message",
118
+ const parsed = JSON.parse(loggedRecords[0]);
119
+ assert.strictEqual(typeof parsed.timestamp, "number");
120
+ assert.ok(
121
+ parsed.timestamp > Date.now() - 2000,
122
+ "the timestamp must be newer than 2 seconds ago",
123
+ );
124
+ // biome-ignore lint/performance/noDelete: Would change behaviour of the test
125
+ delete parsed.timestamp;
126
+ assert.deepStrictEqual(parsed, {
127
+ level: 20,
128
+ level_name: "DEBUG",
129
+ hostname: hostname(),
130
+ message: "test message",
131
+ });
131
132
  });
132
133
  });
133
134
 
134
- test("Fields are redacted as expected", async (t) => {
135
- const { logger, loggedRecordsMethod } = buildLogger({
136
- ...getLoggerConfiguration(),
137
- });
138
- logger.warn(toRedactFields.input_value);
135
+ describe("Fields are redacted as expected", () => {
136
+ it("should pass", async () => {
137
+ const { logger, loggedRecordsMethod } = buildLogger({
138
+ ...getLoggerConfiguration(),
139
+ });
140
+ logger.warn(toRedactFields.input_value);
139
141
 
140
- const loggedRecords = loggedRecordsMethod();
141
- const parsed = JSON.parse(loggedRecords[0]);
142
- delete parsed.hostname;
143
- delete parsed.level;
144
- delete parsed.level_name;
145
- delete parsed.timestamp;
142
+ const loggedRecords = loggedRecordsMethod();
143
+ const parsed = JSON.parse(loggedRecords[0]);
144
+ // biome-ignore lint/performance/noDelete: Would change behaviour of the test
145
+ delete parsed.hostname;
146
+ // biome-ignore lint/performance/noDelete: Would change behaviour of the test
147
+ delete parsed.level;
148
+ // biome-ignore lint/performance/noDelete: Would change behaviour of the test
149
+ delete parsed.level_name;
150
+ // biome-ignore lint/performance/noDelete: Would change behaviour of the test
151
+ delete parsed.timestamp;
146
152
 
147
- assert.deepStrictEqual(parsed, toRedactFields.expected_output);
153
+ assert.deepStrictEqual(parsed, toRedactFields.expected_output);
154
+ });
148
155
  });
149
156
 
150
- methodsDataProvider.forEach((methodDataProvider) =>
151
- test(`Methods are writing correct levels - ${methodDataProvider.method}`, async (t) => {
152
- const { logger, loggedRecordsMethod } = buildLogger({
153
- ...getLoggerConfiguration("trace"),
154
- });
157
+ for (const methodDataProvider of methodsDataProvider) {
158
+ describe(`Methods are writing correct levels - ${methodDataProvider.method}`, () => {
159
+ it("should pass", async () => {
160
+ const { logger, loggedRecordsMethod } = buildLogger({
161
+ ...getLoggerConfiguration("trace"),
162
+ });
155
163
 
156
- logger[methodDataProvider.method]("test");
164
+ logger[methodDataProvider.method]("test");
157
165
 
158
- const loggedRecords = loggedRecordsMethod();
159
- assert.strictEqual(loggedRecords.length, 1);
160
- const parsed = JSON.parse(loggedRecords[0]);
166
+ const loggedRecords = loggedRecordsMethod();
167
+ assert.strictEqual(loggedRecords.length, 1);
168
+ const parsed = JSON.parse(loggedRecords[0]);
161
169
 
162
- assert.strictEqual(parsed.level, methodDataProvider.expected.level);
163
- assert.strictEqual(
164
- parsed.level_name,
165
- methodDataProvider.expected.level_name,
166
- );
167
- }),
168
- );
170
+ assert.strictEqual(parsed.level, methodDataProvider.expected.level);
171
+ assert.strictEqual(
172
+ parsed.level_name,
173
+ methodDataProvider.expected.level_name,
174
+ );
175
+ });
176
+ });
177
+ }
@@ -1,5 +1,5 @@
1
- import { FastifyServerOptions, FastifyInstance } from "fastify";
2
- import { DestinationStream } from "pino";
1
+ import type { FastifyServerOptions, FastifyInstance } from "fastify";
2
+ import { type DestinationStream } from "pino";
3
3
  export declare const initializeLoggingHooks: (server: FastifyInstance) => void;
4
4
  export declare const getLoggingConfiguration: (loggerDestination?: DestinationStream) => FastifyServerOptions;
5
5
  //# sourceMappingURL=fastify-logging-wrapper.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"fastify-logging-wrapper.d.ts","sourceRoot":"","sources":["../src/fastify-logging-wrapper.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AAchE,OAAO,EAAQ,iBAAiB,EAAE,MAAM,MAAM,CAAC;AAK/C,eAAO,MAAM,sBAAsB,WAAY,eAAe,KAAG,IA6BhE,CAAC;AAEF,eAAO,MAAM,uBAAuB,uBACd,iBAAiB,KACpC,oBAMD,CAAC"}
1
+ {"version":3,"file":"fastify-logging-wrapper.d.ts","sourceRoot":"","sources":["../src/fastify-logging-wrapper.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,oBAAoB,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AAcrE,OAAO,EAAQ,KAAK,iBAAiB,EAAE,MAAM,MAAM,CAAC;AAKpD,eAAO,MAAM,sBAAsB,WAAY,eAAe,KAAG,IA6BhE,CAAC;AAEF,eAAO,MAAM,uBAAuB,uBACd,iBAAiB,KACpC,oBAMD,CAAC"}
@@ -25,7 +25,7 @@ export const initializeLoggingHooks = (server) => {
25
25
  });
26
26
  };
27
27
  export const getLoggingConfiguration = (loggerDestination) => ({
28
- loggerInstance: pino(getLoggerConfiguration(), loggerDestination),
28
+ logger: pino(getLoggerConfiguration(), loggerDestination),
29
29
  disableRequestLogging: true,
30
30
  genReqId: () => hyperidInstance(),
31
31
  requestIdLogLabel: REQUEST_ID_LOG_LABEL,
@@ -1 +1 @@
1
- {"version":3,"file":"fastify-logging-wrapper.js","sourceRoot":"","sources":["../src/fastify-logging-wrapper.ts"],"names":[],"mappings":"AACA,OAAO,OAAO,MAAM,SAAS,CAAC;AAC9B,OAAO,EACL,WAAW,EACX,oBAAoB,GACrB,MAAM,+BAA+B,CAAC;AACvC,OAAO,EACL,sBAAsB,EACtB,sBAAsB,EACtB,6BAA6B,EAC7B,uBAAuB,EACvB,mBAAmB,EACnB,iBAAiB,GAClB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAE,IAAI,EAAqB,MAAM,MAAM,CAAC;AAC/C,OAAO,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AAEzD,MAAM,eAAe,GAAG,OAAO,CAAC,EAAE,WAAW,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC,CAAC;AAEtE,MAAM,CAAC,MAAM,sBAAsB,GAAG,CAAC,MAAuB,EA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AG,CAAC,IAAI,CAAC,WAAW,CAAC,QAAQ,CAAC,CAAC;QACrC,uCAAuC;QACvC,KAAK,CAAC,GAAG,CAAC,IAAI,CACZ,EAAE,KAAK,EAAE,6BAA6B,EAAE,EAAE,EAC1C,WAAW,CAAC,QAAQ,CACrB,CAAC;QACF,mBAAmB,EAAE,CAAC;QACtB,IAAI,EAAE,CAAC;IACT,CAAC,CAAC,CAAC;IAEH,MAAM,CAAC,OAAO,CAAC,SAAS,EAAE,CAAC,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,IAAI,EAAE,EAAE;QACzD,iBAAiB,CAAC,EAAE,KAAK,EAAE,CAAC,CAAC;QAE7B,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE,KAAK,EAAE,sBAAsB,EAAE,EAAE,EAAE,WAAW,CAAC,KAAK,CAAC,CAAC;QAE1E,IAAI,EAAE,CAAC;IACT,CAAC,CAAC,CAAC;AACL,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,uBAAuB,GAAG,CACrC,iBAAqC,EACf,EAAE,CAAC,CAAC;IAC1B,MAAM,EAAE,IAAI,CAAC,sBAAsB,EAAE,EAAE,iBAAiB,CAAC;IACzD,qBAAqB,EAAE,IAAI;IAC3B,QAAQ,EAAE,GAAG,EAAE,CAAC,eAAe,EAAE;IACjC,iBAAiB,EAAE,oBAAoB;IACvC,eAAe,EAAE,iBAAiB;CACnC,CAAC,CAAC"}
package/dist/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
1
  export { getLoggingConfiguration, initializeLoggingHooks, } from "./fastify-logging-wrapper.js";
2
2
  export { toLoggingError, LogMessages, LoggingError, } from "./logging-wrapper-entities.js";
3
- export { getLoggingContextError, setLoggingContext } from "./logging-wrapper.js";
3
+ export { getLoggingContextError, setLoggingContext, } from "./logging-wrapper.js";
4
4
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,uBAAuB,EACvB,sBAAsB,GACvB,MAAM,8BAA8B,CAAC;AACtC,OAAO,EACL,cAAc,EACd,WAAW,EACX,YAAY,GACb,MAAM,+BAA+B,CAAC;AAEvC,OAAO,EAAE,sBAAsB,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,uBAAuB,EACvB,sBAAsB,GACvB,MAAM,8BAA8B,CAAC;AACtC,OAAO,EACL,cAAc,EACd,WAAW,EACX,YAAY,GACb,MAAM,+BAA+B,CAAC;AAEvC,OAAO,EACL,sBAAsB,EACtB,iBAAiB,GAClB,MAAM,sBAAsB,CAAC"}
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
1
  export { getLoggingConfiguration, initializeLoggingHooks, } from "./fastify-logging-wrapper.js";
2
2
  export { toLoggingError, LogMessages, } from "./logging-wrapper-entities.js";
3
- export { getLoggingContextError, setLoggingContext } from "./logging-wrapper.js";
3
+ export { getLoggingContextError, setLoggingContext, } from "./logging-wrapper.js";
4
4
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,uBAAuB,EACvB,sBAAsB,GACvB,MAAM,8BAA8B,CAAC;AACtC,OAAO,EACL,cAAc,EACd,WAAW,GAEZ,MAAM,+BAA+B,CAAC;AAEvC,OAAO,EAAE,sBAAsB,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,uBAAuB,EACvB,sBAAsB,GACvB,MAAM,8BAA8B,CAAC;AACtC,OAAO,EACL,cAAc,EACd,WAAW,GAEZ,MAAM,+BAA+B,CAAC;AAEvC,OAAO,EACL,sBAAsB,EACtB,iBAAiB,GAClB,MAAM,sBAAsB,CAAC"}
@@ -1,12 +1,11 @@
1
- import { FastifyError } from "fastify";
2
- import { HttpError } from "@fastify/sensible";
1
+ import type { FastifyError } from "fastify";
2
+ import type { HttpError } from "@fastify/sensible";
3
3
  export interface LoggingRequest {
4
4
  scheme: string;
5
5
  method: string;
6
6
  path: string | undefined;
7
7
  hostname: string;
8
8
  query_params: unknown;
9
- port: number;
10
9
  [key: string]: unknown;
11
10
  }
12
11
  export interface FullLoggingRequest extends LoggingRequest {
@@ -1 +1 @@
1
- {"version":3,"file":"logging-wrapper-entities.d.ts","sourceRoot":"","sources":["../src/logging-wrapper-entities.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAIvC,OAAO,EAAE,SAAS,EAAC,MAAM,mBAAmB,CAAC;AAG7C,MAAM,WAAW,cAAc;IAC7B,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,MAAM,GAAG,SAAS,CAAC;IACzB,QAAQ,EAAE,MAAM,CAAC;IACjB,YAAY,EAAE,OAAO,CAAC;IACtB,IAAI,EAAE,MAAM,CAAC;IACb,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;CACxB;AAED,MAAM,WAAW,kBAAmB,SAAQ,cAAc;IACxD,OAAO,EAAE,OAAO,CAAC;IACjB,UAAU,EAAE,MAAM,GAAG,SAAS,CAAC;IAC/B,SAAS,EAAE,MAAM,CAAC;CACnB;AAED,MAAM,WAAW,eAAe;IAC9B,OAAO,EAAE,OAAO,CAAC;IACjB,WAAW,EAAE,MAAM,CAAC;IACpB,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;CACxB;AAED,MAAM,WAAW,YAAY;IAC3B,KAAK,EAAE,eAAe,CAAC;IACvB,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,C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ForLogging } from "@ogcio/shared-errors";
2
2
  import { isHttpError } from "http-errors";
3
3
  export var LogMessages;
4
4
  (function (LogMessages) {
@@ -1 +1 @@
1
- {"version":3,"file":"logging-wrapper-entities.js","sourceRoot":"","sources":["../src/logging-wrapper-entities.ts"],"names":[],"mappings":"AACA,OAAO,EACL,oBAAoB,GACrB,MAAM,sBAAsB,CAAC;AAE9B,OAAO,EAAC,WAAW,EAAC,MAAM,aAAa,CAAC;AAsCxC,MAAM,CAAN,IAAY,WAKX;AALD,WAAY,WAAW;IACrB,yCAA0B,CAAA;IAC1B,oCAAqB,CAAA;IACrB,8BAAe,CAAA;IACf,qCAAsB,CAAA;AACxB,CAAC,EALW,WAAW,KAAX,WAAW,QAKtB;AAED,MAAM,CAAN,IAAY,eAMX;AAND,WAAY,eAAe;IACzB,+CAA4B,CAAA;IAC5B,uDAAoC,CAAA;IACpC,iDAA8B,CAAA;IAC9B,iDAA8B,CAAA;IAC9B,iDAA8B,CAAA;AAChC,CAAC,EANW,eAAe,KAAf,eAAe,QAM1B;AAED,MAAM,CAAC,MAAM,cAAc,GAAG,YAAY,CAAC;AAE3C,MAAM,CAAC,MAAM,cAAc,GAAG;IAC5B,mCAAmC;IACnC,wBAAwB;IACxB,4BAA4B;IAC5B,qBAAqB;IACrB,yBAAyB;IACzB,kCAAkC;CACnC,CAAC;AAEF,MAAM,CAAC,MAAM,WAAW,GAAG,SAAS,CAAC;AAErC,MAAM,CAAC,MAAM,oBAAoB,GAAG,YAAY,CAAC;AAEjD,MAAM,wBAAwB,GAAG,qBAAqB,CAAC;AAEvD,MAAM,CAAC,MAAM,cAAc,GAAG,CAC5B,KAA+B,EACjB,EAAE;IAChB,MAAM,MAAM,GAAG;QACb,KAAK,EAAE,eAAe,CAAC,KAAK,CAAC;QAC7B,OAAO,EAAE,KAAK,CAAC,OAAO;QACtB,KAAK,EAAE,KAAK,CAAC,KAAK;KACnB,CAAC;IAEF,IAAI,WAAW,CAAC,KAAK,CAAC,EAAE,CAAC;QACvB,MAAM,WAAW,GAAG,KAAK,CAAC,WAAW,IAAI,KAAK,CAAC,MAAM,CAAC;QACtD,MAAM,MAAM,GAAG,WAAW;YACxB,CAAC,CAAC,EAAE,MAAM,EAAE,oBAAoB,CAAC,WAAW,CAAC,EAAE;YAC/C,CAAC,CAAC,EAAE,CAAC;QAEP,OAAO;YACL,GAAG,MAAM;YACT,IAAI,EAAE,KAAK,CAAC,IAAI;YAChB,OAAO,EAAE,KAAK,CAAC,YAAY;YAC3B,GAAG,MAAM;SACV,CAAC;IACJ,CAAC;IAED,OAAO;QACL,GAAG,MAAM;QACT,IAAI,EAAE,KAAK,CAAC,IAAI,IAAI,wBAAwB;KAC7C,CAAC;AACJ,CAAC,CAAC;AAEF,MAAM,eAAe,GAAG,CACtB,KAA+B,EACd,EAAE;IACnB,IAAI,CAAC,KAAK,CAAC,UAAU,EAAE,CAAC;QACtB,OAAO,eAAe,CAAC,YAAY,CAAC;IACtC,CAAC;IAED,MAAM,UAAU,GAAG,MAAM,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC;IAE5C,IAAI,UAAU,KAAK,GAAG,EAAE,CAAC;QACvB,OAAO,eAAe,CAAC,YAAY,CAAC;IACtC,CAAC;IAED,IAAI,UAAU,IAAI,GAAG,EAAE,CAAC;QACtB,OAAO,eAAe,CAAC,WAAW,CAAC;IACrC,CAAC;IAED,IAAI,UAAU,KAAK,GAAG,EAAE,CAAC;QACvB,OAAO,eAAe,CAAC,eAAe,CAAC;IACzC,CAAC;IAED,IAAI,UAAU,IAAI,GAAG,EAAE,CAAC;QACtB,OAAO,eAAe,CAAC,YAAY,CAAC;IACtC,CAAC;IAED,OAAO,eAAe,CAAC,YAAY,CAAC;AACtC,CAAC,CAAC"}
1
+ {"version":3,"file":"logging-wrapper-entities.js","sourceRoot":"","sources":["../src/logging-wrapper-entities.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAC;AAE5D,OAAO,EAAE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,KAAK,CAAC,IAAI;YAChB,OAAO,EAAE,KAAK,CAAC,YAAY;YAC3B,GAAG,MAAM;SACV,CAAC;IACJ,CAAC;IAED,OAAO;QACL,GAAG,MAAM;QACT,IAAI,EAAE,KAAK,CAAC,IAAI,IAAI,wBAAwB;KAC7C,CAAC;AACJ,CAAC,CAAC;AAEF,MAAM,eAAe,GAAG,CAAC,KAA+B,EAAmB,EAAE;IAC3E,IAAI,CAAC,KAAK,CAAC,UAAU,EAAE,CAAC;QACtB,OAAO,eAAe,CAAC,YAAY,CAAC;IACtC,CAAC;IAED,MAAM,UAAU,GAAG,MAAM,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC;IAE5C,IAAI,UAAU,KAAK,GAAG,EAAE,CAAC;QACvB,OAAO,eAAe,CAAC,YAAY,CAAC;IACtC,CAAC;IAED,IAAI,UAAU,IAAI,GAAG,EAAE,CAAC;QACtB,OAAO,eAAe,CAAC,WAAW,CAAC;IACrC,CAAC;IAED,IAAI,UAAU,KAAK,GAAG,EAAE,CAAC;QACvB,OAAO,eAAe,CAAC,eAAe,CAAC;IACzC,CAAC;IAED,IAAI,UAAU,IAAI,GAAG,EAAE,CAAC;QACtB,OAAO,eAAe,CAAC,YAAY,CAAC;IACtC,CAAC;IAED,OAAO,eAAe,CAAC,YAAY,CAAC;AACtC,CAAC,CAAC"}
@@ -1,7 +1,7 @@
1
- import { FastifyRequest, FastifyReply, FastifyError } from "fastify";
2
- import { LoggingContext, FullLoggingRequest, LoggingError } from "./logging-wrapper-entities.js";
3
- import { LogLevel, PinoLoggerOptions } from "fastify/types/logger.js";
4
- import { HttpError } from "@fastify/sensible";
1
+ import type { FastifyRequest, FastifyReply, FastifyError } from "fastify";
2
+ import { type LoggingContext, type FullLoggingRequest, type LoggingError } from "./logging-wrapper-entities.js";
3
+ import type { LogLevel, PinoLoggerOptions } from "fastify/types/logger.js";
4
+ import type { HttpError } from "@fastify/sensible";
5
5
  type INPUT_ERROR_TYPES = FastifyError | HttpError;
6
6
  export declare const getLoggingContext: (params: {
7
7
  includeError: boolean;
@@ -1 +1 @@
1
- {"version":3,"file":"logging-wrapper.d.ts","sourceRoot":"","sources":["../src/logging-wrapper.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAErE,OAAO,EACL,cAAc,EAEd,kBAAkB,EAElB,YAAY,EAKb,MAAM,+BAA+B,CAAC;AACvC,OAAO,EAAE,QAAQ,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AACtE,OAAO,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAI9C,KAAK,iBAAiB,GAAG,YAAY,GAAG,SAAS,CAAC;AAElD,eAAO,MAAM,iBAAiB,WAAY;IACxC,YAAY,EAAE,OAAO,CAAC;CACvB,KAAG,cAGyC,CAAC;AAE9C,eAAO,MAAM,iBAAiB,WAAY;IACxC,OAAO,CAAC,EAAE,cAAc,CAAC;IACzB,QAAQ,CAAC,EAAE,YAAY,CAAC;IACxB,KAAK,CAAC,EAAE,iBAAiB,CAAC;CAC3B,KAAG,IAUH,CAAC;AAEF,eAAO,MAAM,mBAAmB,QAAO,IAItC,CAAC;AAEF,eAAO,MAAM,sBAAsB,QAAO,YAAY,GAAG,SACR,CAAC;AAElD,eAAO,MAAM,6BAA6B,QACtC,IAAI,CAAC,YAAY,EAAE,OAAO,CAAC,GAC3B,SAGF,CAAC;AAcH,eAAO,MAAM,uBAAuB,QAC7B,cAAc,KAClB,kBAKD,CAAC;AAOH,eAAO,MAAM,sBAAsB,kBACnB,QAAQ,KACrB,iBAmBD,CAAC"}
1
+ {"version":3,"file":"logging-wrapper.d.ts","sourceRoot":"","sources":["../src/logging-wrapper.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAE1E,OAAO,EACL,KAAK,cAAc,EAEnB,KAAK,kBAAkB,EAEvB,KAAK,YAAY,EAKlB,MAAM,+BAA+B,CAAC;AACvC,OAAO,KAAK,EAAE,QAAQ,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAC3E,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAInD,KAAK,iBAAiB,GAAG,YAAY,GAAG,SAAS,CAAC;AAElD,eAAO,MAAM,iBAAiB,WAAY;IACxC,YAAY,EAAE,OAAO,CAAC;CACvB,KAAG,cAGyC,CAAC;AAE9C,eAAO,MAAM,iBAAiB,WAAY;IACxC,OAAO,CAAC,EAAE,cAAc,CAAC;IACzB,QAAQ,CAAC,EAAE,YAAY,CAAC;IACxB,KAAK,CAAC,EAAE,iBAAiB,CAAC;CAC3B,KAAG,IAUH,CAAC;AAEF,eAAO,MAAM,mBAAmB,QAAO,IAItC,CAAC;AAEF,eAAO,MAAM,sBAAsB,QAAO,YAAY,GAAG,SACR,CAAC;AAElD,eAAO,MAAM,6BAA6B,QACtC,IAAI,CAAC,YAAY,EAAE,OAAO,CAAC,GAC3B,SAGF,CAAC;AAaH,eAAO,MAAM,uBAAuB,QAC7B,cAAc,KAClB,kBAKD,CAAC;AAOH,eAAO,MAAM,sBAAsB,kBACnB,QAAQ,KACrB,iBAmBD,CAAC"}
@@ -32,7 +32,6 @@ const parseLoggingRequest = (req) => ({
32
32
  path: getPathWithoutParams(req),
33
33
  hostname: req.hostname,
34
34
  query_params: req.query,
35
- port: req.port,
36
35
  });
37
36
  export const parseFullLoggingRequest = (req) => ({
38
37
  ...parseLoggingRequest(req),
@@ -1 +1 @@
1
- {"version":3,"file":"logging-wrapper.js","sourceRoot":"","sources":["../src/logging-wrapper.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,MAAM,IAAI,CAAC;AAC9B,OAAO,EAML,cAAc,EACd,cAAc,EACd,WAAW,EACX,cAAc,GACf,MAAM,+BAA+B,CAAC;AAIvC,MAAM,cAAc,GAAmB,EAAE,CAAC;AAI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,CAAC,CAAC;AAEH,MAAM,oBAAoB,GAAG,CAAC,GAAiB,EAAmB,EAAE,CAAC,CAAC;IACpE,WAAW,EAAE,GAAG,CAAC,UAAU;IAC3B,OAAO,EAAE,GAAG,CAAC,UAAU,EAAE;CAC1B,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,sBAAsB,GAAG,CACpC,eAAyB,OAAO,EACb,EAAE,CAAC,CAAC;IACvB,IAAI,EAAE,EAAE,QAAQ,EAAE,QAAQ,EAAE,EAAE;IAC9B,UAAU,EAAE,WAAW;IACvB,KAAK,EAAE,GAAG,EAAE,CAAC,CAAC;QACZ,SAAS,EAAE,IAAI,CAAC,GAAG,EAAE;QACrB,GAAG,iBAAiB,CAAC,EAAE,YAAY,EAAE,KAAK,EAAE,CAAC;KAC9C,CAAC;IACF,MAAM,EAAE;QACN,KAAK,EAAE,cAAc;QACrB,MAAM,EAAE,cAAc;KACvB;IACD,SAAS,EAAE,KAAK;IAChB,UAAU,EAAE;QACV,KAAK,EAAE,CAAC,IAAY,EAAE,QAAgB,EAAE,EAAE,CAAC,CAAC;YAC1C,KAAK,EAAE,QAAQ;YACf,UAAU,EAAE,IAAI,CAAC,WAAW,EAAE;SAC/B,CAAC;KACH;IACD,KAAK,EAAE,YAAY;CACpB,CAAC,CAAC"}
package/package.json CHANGED
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "@ogcio/fastify-logging-wrapper",
3
- "version": "5.0.2",
3
+ "version": "5.1.0",
4
4
  "main": "dist/index.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "type": "module",
7
7
  "scripts": {
8
8
  "build": "rm -rf dist tsconfig.prod.tsbuildinfo tsconfig.tsbuildinfo && tsc -p tsconfig.prod.json",
9
- "test": "tap --jobs=1 --allow-incomplete-coverage __tests__/**/*.test.ts"
9
+ "test": "vitest run --coverage --outputFile=results.xml"
10
10
  },
11
11
  "keywords": [],
12
12
  "author": {
@@ -19,7 +19,7 @@
19
19
  "@fastify/error": "^4.0.0",
20
20
  "@fastify/sensible": "^6.0.1",
21
21
  "@ogcio/shared-errors": "^1.0.0",
22
- "fastify": "^5.0.0",
22
+ "fastify": "^5.1.0",
23
23
  "hyperid": "^3.3.0"
24
24
  },
25
25
  "devDependencies": {
@@ -1,4 +1,4 @@
1
- import { FastifyServerOptions, FastifyInstance } from "fastify";
1
+ import type { FastifyServerOptions, FastifyInstance } from "fastify";
2
2
  import hyperid from "hyperid";
3
3
  import {
4
4
  LogMessages,
@@ -12,8 +12,9 @@ import {
12
12
  resetLoggingContext,
13
13
  setLoggingContext,
14
14
  } from "./logging-wrapper.js";
15
- import { pino, DestinationStream } from "pino";
15
+ import { pino, type DestinationStream } from "pino";
16
16
  import { REQUEST_ID_HEADER } from "@ogcio/shared-errors";
17
+ import type { PinoLoggerOptions } from "fastify/types/logger.js";
17
18
 
18
19
  const hyperidInstance = hyperid({ fixedLength: true, urlSafe: true });
19
20
 
@@ -48,12 +49,27 @@ export const initializeLoggingHooks = (server: FastifyInstance): void => {
48
49
  });
49
50
  };
50
51
 
51
- export const getLoggingConfiguration = (
52
- loggerDestination?: DestinationStream,
53
- ): FastifyServerOptions => ({
54
- loggerInstance: pino(getLoggerConfiguration(), loggerDestination),
55
- disableRequestLogging: true,
56
- genReqId: () => hyperidInstance(),
57
- requestIdLogLabel: REQUEST_ID_LOG_LABEL,
58
- requestIdHeader: REQUEST_ID_HEADER,
59
- });
52
+ export const getLoggingConfiguration = (customConfig?: {
53
+ pinoOptions?: PinoLoggerOptions;
54
+ loggerDestination?: DestinationStream;
55
+ }): FastifyServerOptions => {
56
+ if (customConfig)
57
+ return {
58
+ loggerInstance: pino(
59
+ { ...getLoggerConfiguration(), ...(customConfig?.pinoOptions ?? {}) },
60
+ customConfig?.loggerDestination,
61
+ ),
62
+ disableRequestLogging: true,
63
+ genReqId: () => hyperidInstance(),
64
+ requestIdLogLabel: REQUEST_ID_LOG_LABEL,
65
+ requestIdHeader: REQUEST_ID_HEADER,
66
+ };
67
+
68
+ return {
69
+ logger: getLoggerConfiguration(),
70
+ disableRequestLogging: true,
71
+ genReqId: () => hyperidInstance(),
72
+ requestIdLogLabel: REQUEST_ID_LOG_LABEL,
73
+ requestIdHeader: REQUEST_ID_HEADER,
74
+ };
75
+ };
package/src/index.ts CHANGED
@@ -8,4 +8,7 @@ export {
8
8
  LoggingError,
9
9
  } from "./logging-wrapper-entities.js";
10
10
 
11
- export { getLoggingContextError, setLoggingContext } from "./logging-wrapper.js";
11
+ export {
12
+ getLoggingContextError,
13
+ setLoggingContext,
14
+ } from "./logging-wrapper.js";
@@ -1,9 +1,7 @@
1
- import { FastifyError } from "fastify";
2
- import {
3
- parseErrorForLogging,
4
- } from "@ogcio/shared-errors";
5
- import { HttpError} from "@fastify/sensible";
6
- import {isHttpError} from "http-errors";
1
+ import type { FastifyError } from "fastify";
2
+ import { parseErrorForLogging } from "@ogcio/shared-errors";
3
+ import type { HttpError } from "@fastify/sensible";
4
+ import { isHttpError } from "http-errors";
7
5
 
8
6
  export interface LoggingRequest {
9
7
  scheme: string;
@@ -102,9 +100,7 @@ export const toLoggingError = (
102
100
  };
103
101
  };
104
102
 
105
- const parseErrorClass = (
106
- error: FastifyError | HttpError,
107
- ): LogErrorClasses => {
103
+ const parseErrorClass = (error: FastifyError | HttpError): LogErrorClasses => {
108
104
  if (!error.statusCode) {
109
105
  return LogErrorClasses.UnknownError;
110
106
  }
@@ -1,18 +1,18 @@
1
- import { FastifyRequest, FastifyReply, FastifyError } from "fastify";
1
+ import type { FastifyRequest, FastifyReply, FastifyError } from "fastify";
2
2
  import { hostname } from "os";
3
3
  import {
4
- LoggingContext,
5
- LoggingRequest,
6
- FullLoggingRequest,
7
- LoggingResponse,
8
- LoggingError,
4
+ type LoggingContext,
5
+ type LoggingRequest,
6
+ type FullLoggingRequest,
7
+ type LoggingResponse,
8
+ type LoggingError,
9
9
  REDACTED_VALUE,
10
10
  REDACTED_PATHS,
11
11
  MESSAGE_KEY,
12
12
  toLoggingError,
13
13
  } from "./logging-wrapper-entities.js";
14
- import { LogLevel, PinoLoggerOptions } from "fastify/types/logger.js";
15
- import { HttpError } from "@fastify/sensible";
14
+ import type { LogLevel, PinoLoggerOptions } from "fastify/types/logger.js";
15
+ import type { HttpError } from "@fastify/sensible";
16
16
 
17
17
  const loggingContext: LoggingContext = {};
18
18
 
@@ -0,0 +1,20 @@
1
+ import { defineConfig } from "vitest/config";
2
+
3
+ export default defineConfig({
4
+ test: {
5
+ reporters: "junit",
6
+ coverage: {
7
+ reporter: ["text"],
8
+ provider: "istanbul",
9
+ },
10
+
11
+ include: [
12
+ "**/@(test?(s)|__test?(s)__)/**/*.test.@(js|cjs|mjs|tap|cts|jsx|mts|ts|tsx)",
13
+ "**/*.@(test?(s)|spec).@(js|cjs|mjs|tap|cts|jsx|mts|ts|tsx)",
14
+ "**/test?(s).@(js|cjs|mjs|tap|cts|jsx|mts|ts|tsx)",
15
+ ],
16
+ exclude: ["**/@(fixture*(s)|dist|node_modules)/**"],
17
+ maxConcurrency: 1,
18
+ testTimeout: 30000, // Timeout in milliseconds (30 seconds)
19
+ },
20
+ });