@forklaunch/core 0.5.3 → 0.5.4
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.
- package/lib/cache/index.d.mts +5 -1
- package/lib/cache/index.d.ts +5 -1
- package/lib/cache/index.js +4 -3
- package/lib/cache/index.js.map +1 -1
- package/lib/cache/index.mjs +4 -3
- package/lib/cache/index.mjs.map +1 -1
- package/lib/http/index.d.mts +36 -35
- package/lib/http/index.d.ts +36 -35
- package/lib/http/index.js +277 -226
- package/lib/http/index.js.map +1 -1
- package/lib/http/index.mjs +279 -230
- package/lib/http/index.mjs.map +1 -1
- package/lib/openTelemetryCollector-CWrfzmmW.d.mts +44 -0
- package/lib/openTelemetryCollector-CWrfzmmW.d.ts +44 -0
- package/lib/services/index.d.mts +9 -3
- package/lib/services/index.d.ts +9 -3
- package/lib/services/index.js +32 -16
- package/lib/services/index.js.map +1 -1
- package/lib/services/index.mjs +32 -16
- package/lib/services/index.mjs.map +1 -1
- package/package.json +1 -1
package/lib/cache/index.d.mts
CHANGED
@@ -1,4 +1,7 @@
|
|
1
1
|
import { RedisClientOptions } from 'redis';
|
2
|
+
import { O as OpenTelemetryCollector, M as MetricsDefinition } from '../openTelemetryCollector-CWrfzmmW.mjs';
|
3
|
+
import '@opentelemetry/api';
|
4
|
+
import 'pino';
|
2
5
|
|
3
6
|
/**
|
4
7
|
* Type representing a TTL (Time-To-Live) cache record.
|
@@ -67,6 +70,7 @@ interface TtlCache {
|
|
67
70
|
*/
|
68
71
|
declare class RedisTtlCache implements TtlCache {
|
69
72
|
private ttlMilliseconds;
|
73
|
+
private openTelemetryCollector;
|
70
74
|
private client;
|
71
75
|
/**
|
72
76
|
* Creates an instance of RedisTtlCache.
|
@@ -74,7 +78,7 @@ declare class RedisTtlCache implements TtlCache {
|
|
74
78
|
* @param {number} ttlMilliseconds - The default TTL in milliseconds.
|
75
79
|
* @param {RedisClientOptions} [hostingOptions] - The Redis client options.
|
76
80
|
*/
|
77
|
-
constructor(ttlMilliseconds: number, hostingOptions?: RedisClientOptions);
|
81
|
+
constructor(ttlMilliseconds: number, openTelemetryCollector: OpenTelemetryCollector<MetricsDefinition>, hostingOptions?: RedisClientOptions);
|
78
82
|
/**
|
79
83
|
* Puts a record into the Redis cache.
|
80
84
|
*
|
package/lib/cache/index.d.ts
CHANGED
@@ -1,4 +1,7 @@
|
|
1
1
|
import { RedisClientOptions } from 'redis';
|
2
|
+
import { O as OpenTelemetryCollector, M as MetricsDefinition } from '../openTelemetryCollector-CWrfzmmW.js';
|
3
|
+
import '@opentelemetry/api';
|
4
|
+
import 'pino';
|
2
5
|
|
3
6
|
/**
|
4
7
|
* Type representing a TTL (Time-To-Live) cache record.
|
@@ -67,6 +70,7 @@ interface TtlCache {
|
|
67
70
|
*/
|
68
71
|
declare class RedisTtlCache implements TtlCache {
|
69
72
|
private ttlMilliseconds;
|
73
|
+
private openTelemetryCollector;
|
70
74
|
private client;
|
71
75
|
/**
|
72
76
|
* Creates an instance of RedisTtlCache.
|
@@ -74,7 +78,7 @@ declare class RedisTtlCache implements TtlCache {
|
|
74
78
|
* @param {number} ttlMilliseconds - The default TTL in milliseconds.
|
75
79
|
* @param {RedisClientOptions} [hostingOptions] - The Redis client options.
|
76
80
|
*/
|
77
|
-
constructor(ttlMilliseconds: number, hostingOptions?: RedisClientOptions);
|
81
|
+
constructor(ttlMilliseconds: number, openTelemetryCollector: OpenTelemetryCollector<MetricsDefinition>, hostingOptions?: RedisClientOptions);
|
78
82
|
/**
|
79
83
|
* Puts a record into the Redis cache.
|
80
84
|
*
|
package/lib/cache/index.js
CHANGED
@@ -34,11 +34,12 @@ var RedisTtlCache = class {
|
|
34
34
|
* @param {number} ttlMilliseconds - The default TTL in milliseconds.
|
35
35
|
* @param {RedisClientOptions} [hostingOptions] - The Redis client options.
|
36
36
|
*/
|
37
|
-
constructor(ttlMilliseconds, hostingOptions) {
|
37
|
+
constructor(ttlMilliseconds, openTelemetryCollector, hostingOptions) {
|
38
38
|
this.ttlMilliseconds = ttlMilliseconds;
|
39
|
+
this.openTelemetryCollector = openTelemetryCollector;
|
39
40
|
this.client = (0, import_redis.createClient)(hostingOptions);
|
40
|
-
this.client.on("error", (err) =>
|
41
|
-
this.client.connect().catch(
|
41
|
+
this.client.on("error", (err) => openTelemetryCollector.error(err));
|
42
|
+
this.client.connect().catch(openTelemetryCollector.error);
|
42
43
|
}
|
43
44
|
client;
|
44
45
|
/**
|
package/lib/cache/index.js.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["../../src/cache/index.ts","../../src/cache/redisTtlCache.ts","../../src/cache/utils/cacheKey.ts"],"sourcesContent":["export * from './interfaces/ttlCache.interface';\nexport * from './redisTtlCache';\nexport * from './types/ttlCacheRecord.types';\nexport * from './utils/cacheKey';\n","import { RedisClientOptions, createClient } from 'redis';\nimport { TtlCache } from './interfaces/ttlCache.interface';\nimport { TtlCacheRecord } from './types/ttlCacheRecord.types';\n\n/**\n * Class representing a Redis-based TTL (Time-To-Live) cache.\n * Implements the TtlCache interface.\n */\nexport class RedisTtlCache implements TtlCache {\n private client;\n\n /**\n * Creates an instance of RedisTtlCache.\n *\n * @param {number} ttlMilliseconds - The default TTL in milliseconds.\n * @param {RedisClientOptions} [hostingOptions] - The Redis client options.\n */\n constructor(\n private ttlMilliseconds: number,\n hostingOptions?: RedisClientOptions\n ) {\n // Connects to localhost:6379 by default\n // url usage: redis[s]://[[username][:password]@][host][:port][/db-number]\n this.client = createClient(hostingOptions);\n this.client.on('error', (err) =>
|
1
|
+
{"version":3,"sources":["../../src/cache/index.ts","../../src/cache/redisTtlCache.ts","../../src/cache/utils/cacheKey.ts"],"sourcesContent":["export * from './interfaces/ttlCache.interface';\nexport * from './redisTtlCache';\nexport * from './types/ttlCacheRecord.types';\nexport * from './utils/cacheKey';\n","import { RedisClientOptions, createClient } from 'redis';\nimport { TtlCache } from './interfaces/ttlCache.interface';\nimport { TtlCacheRecord } from './types/ttlCacheRecord.types';\nimport { OpenTelemetryCollector } from '../http/telemetry/openTelemetryCollector';\nimport { MetricsDefinition } from '../http';\n\n/**\n * Class representing a Redis-based TTL (Time-To-Live) cache.\n * Implements the TtlCache interface.\n */\nexport class RedisTtlCache implements TtlCache {\n private client;\n\n /**\n * Creates an instance of RedisTtlCache.\n *\n * @param {number} ttlMilliseconds - The default TTL in milliseconds.\n * @param {RedisClientOptions} [hostingOptions] - The Redis client options.\n */\n constructor(\n private ttlMilliseconds: number,\n private openTelemetryCollector: OpenTelemetryCollector<MetricsDefinition>,\n hostingOptions?: RedisClientOptions\n ) {\n // Connects to localhost:6379 by default\n // url usage: redis[s]://[[username][:password]@][host][:port][/db-number]\n this.client = createClient(hostingOptions);\n this.client.on('error', (err) => openTelemetryCollector.error(err));\n this.client.connect().catch(openTelemetryCollector.error);\n }\n\n /**\n * Puts a record into the Redis cache.\n *\n * @param {TtlCacheRecord} param0 - The cache record to put into the cache.\n * @returns {Promise<void>} - A promise that resolves when the record is put into the cache.\n */\n async putRecord<T>({\n key,\n value,\n ttlMilliseconds = this.ttlMilliseconds\n }: TtlCacheRecord<T>): Promise<void> {\n await this.client.set(key, JSON.stringify(value), {\n PX: ttlMilliseconds\n });\n }\n\n /**\n * Deletes a record from the Redis cache.\n *\n * @param {string} cacheRecordKey - The key of the cache record to delete.\n * @returns {Promise<void>} - A promise that resolves when the record is deleted from the cache.\n */\n async deleteRecord(cacheRecordKey: string): Promise<void> {\n await this.client.del(cacheRecordKey);\n }\n\n /**\n * Reads a record from the Redis cache.\n *\n * @param {string} cacheRecordKey - The key of the cache record to read.\n * @returns {Promise<TtlCacheRecord>} - A promise that resolves with the cache record.\n * @throws {Error} - Throws an error if the record is not found.\n */\n async readRecord<T>(cacheRecordKey: string): Promise<TtlCacheRecord<T>> {\n const value = await this.client.get(cacheRecordKey);\n if (value === null) {\n throw new Error(`Record not found for key: ${cacheRecordKey}`);\n }\n const ttl = await this.client.ttl(cacheRecordKey); // Fetch TTL from Redis\n return {\n key: cacheRecordKey,\n value: JSON.parse(value),\n ttlMilliseconds: ttl * 1000\n };\n }\n\n /**\n * Lists the keys in the Redis cache that match a pattern prefix.\n *\n * @param {string} pattern_prefix - The pattern prefix to match.\n * @returns {Promise<string[]>} - A promise that resolves with an array of keys matching the pattern prefix.\n */\n async listKeys(pattern_prefix: string): Promise<string[]> {\n const keys = await this.client.keys(pattern_prefix + '*');\n return keys;\n }\n\n /**\n * Peeks at a record in the Redis cache to check if it exists.\n *\n * @param {string} cacheRecordKey - The key of the cache record to peek at.\n * @returns {Promise<boolean>} - A promise that resolves with a boolean indicating if the record exists.\n */\n async peekRecord(cacheRecordKey: string): Promise<boolean> {\n const result = await this.client.exists(cacheRecordKey);\n return result === 1;\n }\n\n /**\n * Disconnects the Redis client.\n *\n * @returns {Promise<void>} - A promise that resolves when the client is disconnected.\n */\n async disconnect(): Promise<void> {\n await this.client.quit();\n }\n\n /**\n * Gets the default TTL (Time-To-Live) in milliseconds.\n *\n * @returns {number} - The TTL in milliseconds.\n */\n getTtlMilliseconds(): number {\n return this.ttlMilliseconds;\n }\n}\n","export const createCacheKey = (cacheKeyPrefix: string) => (id: string) => {\n return `${cacheKeyPrefix}:${id}`;\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,mBAAiD;AAU1C,IAAM,gBAAN,MAAwC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAS7C,YACU,iBACA,wBACR,gBACA;AAHQ;AACA;AAKR,SAAK,aAAS,2BAAa,cAAc;AACzC,SAAK,OAAO,GAAG,SAAS,CAAC,QAAQ,uBAAuB,MAAM,GAAG,CAAC;AAClE,SAAK,OAAO,QAAQ,EAAE,MAAM,uBAAuB,KAAK;AAAA,EAC1D;AAAA,EAlBQ;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EA0BR,MAAM,UAAa;AAAA,IACjB;AAAA,IACA;AAAA,IACA,kBAAkB,KAAK;AAAA,EACzB,GAAqC;AACnC,UAAM,KAAK,OAAO,IAAI,KAAK,KAAK,UAAU,KAAK,GAAG;AAAA,MAChD,IAAI;AAAA,IACN,CAAC;AAAA,EACH;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQA,MAAM,aAAa,gBAAuC;AACxD,UAAM,KAAK,OAAO,IAAI,cAAc;AAAA,EACtC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EASA,MAAM,WAAc,gBAAoD;AACtE,UAAM,QAAQ,MAAM,KAAK,OAAO,IAAI,cAAc;AAClD,QAAI,UAAU,MAAM;AAClB,YAAM,IAAI,MAAM,6BAA6B,cAAc,EAAE;AAAA,IAC/D;AACA,UAAM,MAAM,MAAM,KAAK,OAAO,IAAI,cAAc;AAChD,WAAO;AAAA,MACL,KAAK;AAAA,MACL,OAAO,KAAK,MAAM,KAAK;AAAA,MACvB,iBAAiB,MAAM;AAAA,IACzB;AAAA,EACF;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQA,MAAM,SAAS,gBAA2C;AACxD,UAAM,OAAO,MAAM,KAAK,OAAO,KAAK,iBAAiB,GAAG;AACxD,WAAO;AAAA,EACT;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQA,MAAM,WAAW,gBAA0C;AACzD,UAAM,SAAS,MAAM,KAAK,OAAO,OAAO,cAAc;AACtD,WAAO,WAAW;AAAA,EACpB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOA,MAAM,aAA4B;AAChC,UAAM,KAAK,OAAO,KAAK;AAAA,EACzB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOA,qBAA6B;AAC3B,WAAO,KAAK;AAAA,EACd;AACF;;;ACpHO,IAAM,iBAAiB,CAAC,mBAA2B,CAAC,OAAe;AACxE,SAAO,GAAG,cAAc,IAAI,EAAE;AAChC;","names":[]}
|
package/lib/cache/index.mjs
CHANGED
@@ -7,11 +7,12 @@ var RedisTtlCache = class {
|
|
7
7
|
* @param {number} ttlMilliseconds - The default TTL in milliseconds.
|
8
8
|
* @param {RedisClientOptions} [hostingOptions] - The Redis client options.
|
9
9
|
*/
|
10
|
-
constructor(ttlMilliseconds, hostingOptions) {
|
10
|
+
constructor(ttlMilliseconds, openTelemetryCollector, hostingOptions) {
|
11
11
|
this.ttlMilliseconds = ttlMilliseconds;
|
12
|
+
this.openTelemetryCollector = openTelemetryCollector;
|
12
13
|
this.client = createClient(hostingOptions);
|
13
|
-
this.client.on("error", (err) =>
|
14
|
-
this.client.connect().catch(
|
14
|
+
this.client.on("error", (err) => openTelemetryCollector.error(err));
|
15
|
+
this.client.connect().catch(openTelemetryCollector.error);
|
15
16
|
}
|
16
17
|
client;
|
17
18
|
/**
|
package/lib/cache/index.mjs.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["../../src/cache/redisTtlCache.ts","../../src/cache/utils/cacheKey.ts"],"sourcesContent":["import { RedisClientOptions, createClient } from 'redis';\nimport { TtlCache } from './interfaces/ttlCache.interface';\nimport { TtlCacheRecord } from './types/ttlCacheRecord.types';\n\n/**\n * Class representing a Redis-based TTL (Time-To-Live) cache.\n * Implements the TtlCache interface.\n */\nexport class RedisTtlCache implements TtlCache {\n private client;\n\n /**\n * Creates an instance of RedisTtlCache.\n *\n * @param {number} ttlMilliseconds - The default TTL in milliseconds.\n * @param {RedisClientOptions} [hostingOptions] - The Redis client options.\n */\n constructor(\n private ttlMilliseconds: number,\n hostingOptions?: RedisClientOptions\n ) {\n // Connects to localhost:6379 by default\n // url usage: redis[s]://[[username][:password]@][host][:port][/db-number]\n this.client = createClient(hostingOptions);\n this.client.on('error', (err) =>
|
1
|
+
{"version":3,"sources":["../../src/cache/redisTtlCache.ts","../../src/cache/utils/cacheKey.ts"],"sourcesContent":["import { RedisClientOptions, createClient } from 'redis';\nimport { TtlCache } from './interfaces/ttlCache.interface';\nimport { TtlCacheRecord } from './types/ttlCacheRecord.types';\nimport { OpenTelemetryCollector } from '../http/telemetry/openTelemetryCollector';\nimport { MetricsDefinition } from '../http';\n\n/**\n * Class representing a Redis-based TTL (Time-To-Live) cache.\n * Implements the TtlCache interface.\n */\nexport class RedisTtlCache implements TtlCache {\n private client;\n\n /**\n * Creates an instance of RedisTtlCache.\n *\n * @param {number} ttlMilliseconds - The default TTL in milliseconds.\n * @param {RedisClientOptions} [hostingOptions] - The Redis client options.\n */\n constructor(\n private ttlMilliseconds: number,\n private openTelemetryCollector: OpenTelemetryCollector<MetricsDefinition>,\n hostingOptions?: RedisClientOptions\n ) {\n // Connects to localhost:6379 by default\n // url usage: redis[s]://[[username][:password]@][host][:port][/db-number]\n this.client = createClient(hostingOptions);\n this.client.on('error', (err) => openTelemetryCollector.error(err));\n this.client.connect().catch(openTelemetryCollector.error);\n }\n\n /**\n * Puts a record into the Redis cache.\n *\n * @param {TtlCacheRecord} param0 - The cache record to put into the cache.\n * @returns {Promise<void>} - A promise that resolves when the record is put into the cache.\n */\n async putRecord<T>({\n key,\n value,\n ttlMilliseconds = this.ttlMilliseconds\n }: TtlCacheRecord<T>): Promise<void> {\n await this.client.set(key, JSON.stringify(value), {\n PX: ttlMilliseconds\n });\n }\n\n /**\n * Deletes a record from the Redis cache.\n *\n * @param {string} cacheRecordKey - The key of the cache record to delete.\n * @returns {Promise<void>} - A promise that resolves when the record is deleted from the cache.\n */\n async deleteRecord(cacheRecordKey: string): Promise<void> {\n await this.client.del(cacheRecordKey);\n }\n\n /**\n * Reads a record from the Redis cache.\n *\n * @param {string} cacheRecordKey - The key of the cache record to read.\n * @returns {Promise<TtlCacheRecord>} - A promise that resolves with the cache record.\n * @throws {Error} - Throws an error if the record is not found.\n */\n async readRecord<T>(cacheRecordKey: string): Promise<TtlCacheRecord<T>> {\n const value = await this.client.get(cacheRecordKey);\n if (value === null) {\n throw new Error(`Record not found for key: ${cacheRecordKey}`);\n }\n const ttl = await this.client.ttl(cacheRecordKey); // Fetch TTL from Redis\n return {\n key: cacheRecordKey,\n value: JSON.parse(value),\n ttlMilliseconds: ttl * 1000\n };\n }\n\n /**\n * Lists the keys in the Redis cache that match a pattern prefix.\n *\n * @param {string} pattern_prefix - The pattern prefix to match.\n * @returns {Promise<string[]>} - A promise that resolves with an array of keys matching the pattern prefix.\n */\n async listKeys(pattern_prefix: string): Promise<string[]> {\n const keys = await this.client.keys(pattern_prefix + '*');\n return keys;\n }\n\n /**\n * Peeks at a record in the Redis cache to check if it exists.\n *\n * @param {string} cacheRecordKey - The key of the cache record to peek at.\n * @returns {Promise<boolean>} - A promise that resolves with a boolean indicating if the record exists.\n */\n async peekRecord(cacheRecordKey: string): Promise<boolean> {\n const result = await this.client.exists(cacheRecordKey);\n return result === 1;\n }\n\n /**\n * Disconnects the Redis client.\n *\n * @returns {Promise<void>} - A promise that resolves when the client is disconnected.\n */\n async disconnect(): Promise<void> {\n await this.client.quit();\n }\n\n /**\n * Gets the default TTL (Time-To-Live) in milliseconds.\n *\n * @returns {number} - The TTL in milliseconds.\n */\n getTtlMilliseconds(): number {\n return this.ttlMilliseconds;\n }\n}\n","export const createCacheKey = (cacheKeyPrefix: string) => (id: string) => {\n return `${cacheKeyPrefix}:${id}`;\n};\n"],"mappings":";AAAA,SAA6B,oBAAoB;AAU1C,IAAM,gBAAN,MAAwC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAS7C,YACU,iBACA,wBACR,gBACA;AAHQ;AACA;AAKR,SAAK,SAAS,aAAa,cAAc;AACzC,SAAK,OAAO,GAAG,SAAS,CAAC,QAAQ,uBAAuB,MAAM,GAAG,CAAC;AAClE,SAAK,OAAO,QAAQ,EAAE,MAAM,uBAAuB,KAAK;AAAA,EAC1D;AAAA,EAlBQ;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EA0BR,MAAM,UAAa;AAAA,IACjB;AAAA,IACA;AAAA,IACA,kBAAkB,KAAK;AAAA,EACzB,GAAqC;AACnC,UAAM,KAAK,OAAO,IAAI,KAAK,KAAK,UAAU,KAAK,GAAG;AAAA,MAChD,IAAI;AAAA,IACN,CAAC;AAAA,EACH;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQA,MAAM,aAAa,gBAAuC;AACxD,UAAM,KAAK,OAAO,IAAI,cAAc;AAAA,EACtC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EASA,MAAM,WAAc,gBAAoD;AACtE,UAAM,QAAQ,MAAM,KAAK,OAAO,IAAI,cAAc;AAClD,QAAI,UAAU,MAAM;AAClB,YAAM,IAAI,MAAM,6BAA6B,cAAc,EAAE;AAAA,IAC/D;AACA,UAAM,MAAM,MAAM,KAAK,OAAO,IAAI,cAAc;AAChD,WAAO;AAAA,MACL,KAAK;AAAA,MACL,OAAO,KAAK,MAAM,KAAK;AAAA,MACvB,iBAAiB,MAAM;AAAA,IACzB;AAAA,EACF;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQA,MAAM,SAAS,gBAA2C;AACxD,UAAM,OAAO,MAAM,KAAK,OAAO,KAAK,iBAAiB,GAAG;AACxD,WAAO;AAAA,EACT;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQA,MAAM,WAAW,gBAA0C;AACzD,UAAM,SAAS,MAAM,KAAK,OAAO,OAAO,cAAc;AACtD,WAAO,WAAW;AAAA,EACpB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOA,MAAM,aAA4B;AAChC,UAAM,KAAK,OAAO,KAAK;AAAA,EACzB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOA,qBAA6B;AAC3B,WAAO,KAAK;AAAA,EACd;AACF;;;ACpHO,IAAM,iBAAiB,CAAC,mBAA2B,CAAC,OAAe;AACxE,SAAO,GAAG,cAAc,IAAI,EAAE;AAChC;","names":[]}
|
package/lib/http/index.d.mts
CHANGED
@@ -1,7 +1,10 @@
|
|
1
1
|
import { AnySchemaValidator, UnboxedObjectSchema, IdiomaticSchema, Schema } from '@forklaunch/validator';
|
2
2
|
import { Prettify, RemoveTrailingSlash, MakePropertyOptionalIfChildrenOptional } from '@forklaunch/common';
|
3
|
-
import { Span
|
3
|
+
import { Span } from '@opentelemetry/api';
|
4
4
|
import { ParsedQs } from 'qs';
|
5
|
+
import { Readable } from 'stream';
|
6
|
+
import { O as OpenTelemetryCollector, M as MetricsDefinition, L as LoggerMeta, a as LogFn } from '../openTelemetryCollector-CWrfzmmW.mjs';
|
7
|
+
export { c as MetricType, h as httpRequestsTotalCounter, b as httpServerDurationHistogram } from '../openTelemetryCollector-CWrfzmmW.mjs';
|
5
8
|
import { OpenAPIObject } from 'openapi3-ts/oas31';
|
6
9
|
import { AnyValueMap } from '@opentelemetry/api-logs';
|
7
10
|
import { LevelWithSilentOrString, LevelWithSilent, Logger } from 'pino';
|
@@ -292,6 +295,8 @@ interface ForklaunchRequest<SV extends AnySchemaValidator, P extends ParamsDicti
|
|
292
295
|
requestSchema: unknown;
|
293
296
|
/** Original path */
|
294
297
|
originalPath: string;
|
298
|
+
/** OpenTelemetry Collector */
|
299
|
+
openTelemetryCollector: OpenTelemetryCollector<MetricsDefinition>;
|
295
300
|
}
|
296
301
|
/**
|
297
302
|
* Represents the types of data that can be sent in a response.
|
@@ -355,6 +360,18 @@ interface ForklaunchResponse<ResBodyMap extends Record<number, unknown>, ResHead
|
|
355
360
|
* @param {string} value - The header value.
|
356
361
|
*/
|
357
362
|
setHeader: <K extends keyof (ResHeaders & ForklaunchResHeaders)>(key: K, value: K extends keyof ForklaunchResHeaders ? ForklaunchResHeaders[K] : ResHeaders[K]) => void;
|
363
|
+
/**
|
364
|
+
* Adds an event listener to the response.
|
365
|
+
* @param {string} event - The event to listen for.
|
366
|
+
* @param {Function} listener - The listener function.
|
367
|
+
*/
|
368
|
+
on(event: 'close', listener: () => void): this;
|
369
|
+
on(event: 'drain', listener: () => void): this;
|
370
|
+
on(event: 'error', listener: (err: Error) => void): this;
|
371
|
+
on(event: 'finish', listener: () => void): this;
|
372
|
+
on(event: 'pipe', listener: (src: Readable) => void): this;
|
373
|
+
on(event: 'unpipe', listener: (src: Readable) => void): this;
|
374
|
+
on(event: string | symbol, listener: (...args: unknown[]) => void): this;
|
358
375
|
/**
|
359
376
|
* Sets the status of the response.
|
360
377
|
* @param {U} code - The status code.
|
@@ -370,6 +387,11 @@ interface ForklaunchResponse<ResBodyMap extends Record<number, unknown>, ResHead
|
|
370
387
|
* @param {string} [data] - Optional data to send.
|
371
388
|
*/
|
372
389
|
end: (data?: string) => void;
|
390
|
+
/**
|
391
|
+
* Sets the content type of the response.
|
392
|
+
* @param {string} type - The content type.
|
393
|
+
*/
|
394
|
+
type: (type: string) => void;
|
373
395
|
/** Local variables */
|
374
396
|
locals: LocalsObj;
|
375
397
|
/** Cors */
|
@@ -618,11 +640,12 @@ declare class ForklaunchExpressLikeRouter<SV extends AnySchemaValidator, BasePat
|
|
618
640
|
#private;
|
619
641
|
readonly schemaValidator: SV;
|
620
642
|
readonly internal: Internal;
|
643
|
+
readonly openTelemetryCollector: OpenTelemetryCollector<MetricsDefinition>;
|
621
644
|
requestHandler: RouterHandler;
|
622
645
|
routers: ForklaunchRouter<SV>[];
|
623
646
|
readonly routes: ForklaunchRoute<SV>[];
|
624
647
|
readonly basePath: BasePath;
|
625
|
-
constructor(basePath: BasePath, schemaValidator: SV, internal: Internal);
|
648
|
+
constructor(basePath: BasePath, schemaValidator: SV, internal: Internal, openTelemetryCollector: OpenTelemetryCollector<MetricsDefinition>);
|
626
649
|
registerRoute<ContractMethod extends Method, Path extends `/${string}`, P extends ParamsObject<SV>, ResBodyMap extends ResponsesObject<SV>, ReqBody extends Body<SV>, ReqQuery extends QueryObject<SV>, ReqHeaders extends HeadersObject<SV>, ResHeaders extends HeadersObject<SV>, LocalsObj extends Record<string, unknown>>(method: ContractMethod, path: Path, registrationMethod: PathBasedHandler<RouterHandler>, contractDetailsOrMiddlewareOrTypedHandler: ContractDetailsOrMiddlewareOrTypedHandler<SV, ContractMethod, Path, P, ResBodyMap, ReqBody, ReqQuery, ReqHeaders, ResHeaders, LocalsObj, BaseRequest, BaseResponse, NextFunction>, ...middlewareOrMiddlewareAndTypedHandler: MiddlewareOrMiddlewareWithTypedHandler<SV, ContractMethod, Path, P, ResBodyMap, ReqBody, ReqQuery, ReqHeaders, ResHeaders, LocalsObj, BaseRequest, BaseResponse, NextFunction>[]): LiveTypeFunction<SV, `${BasePath}${Path}`, P, ResBodyMap, ReqBody, ReqQuery, ReqHeaders, ResHeaders>;
|
627
650
|
registerMiddlewareHandler<Path extends `/${string}`, P extends ParamsObject<SV>, ResBodyMap extends ResponsesObject<SV>, ReqBody extends Body<SV>, ReqQuery extends QueryObject<SV>, ReqHeaders extends HeadersObject<SV>, ResHeaders extends HeadersObject<SV>, LocalsObj extends Record<string, unknown>>(registrationMethod: PathOrMiddlewareBasedHandler<RouterHandler>, pathOrContractDetailsOrMiddlewareOrTypedHandler: Path | ContractDetailsOrMiddlewareOrTypedHandler<SV, 'middleware', Path, P, ResBodyMap, ReqBody, ReqQuery, ReqHeaders, ResHeaders, LocalsObj, BaseRequest, BaseResponse, NextFunction>, contractDetailsOrMiddlewareOrTypedHandler?: ContractDetailsOrMiddlewareOrTypedHandler<SV, 'middleware', Path, P, ResBodyMap, ReqBody, ReqQuery, ReqHeaders, ResHeaders, LocalsObj, BaseRequest, BaseResponse, NextFunction>, ...middlewareOrMiddlewareWithTypedHandler: MiddlewareOrMiddlewareWithTypedHandler<SV, 'middleware', Path, P, ResBodyMap, ReqBody, ReqQuery, ReqHeaders, ResHeaders, LocalsObj, BaseRequest, BaseResponse, NextFunction>[]): this;
|
628
651
|
registerNestableMiddlewareHandler<Path extends `/${string}`, P extends ParamsObject<SV>, ResBodyMap extends ResponsesObject<SV>, ReqBody extends Body<SV>, ReqQuery extends QueryObject<SV>, ReqHeaders extends HeadersObject<SV>, ResHeaders extends HeadersObject<SV>, LocalsObj extends Record<string, unknown>>(registrationMethod: NestableRouterBasedHandler<RouterHandler, Internal>, pathOrContractDetailsOrMiddlewareOrTypedHandler: Path | ContractDetailsOrMiddlewareOrTypedHandler<SV, 'middleware', Path, P, ResBodyMap, ReqBody, ReqQuery, ReqHeaders, ResHeaders, LocalsObj, BaseRequest, BaseResponse, NextFunction> | ConstrainedForklaunchRouter<SV, RouterHandler>, contractDetailsOrMiddlewareOrTypedHandler?: ContractDetailsOrMiddlewareOrTypedHandler<SV, 'middleware', Path, P, ResBodyMap, ReqBody, ReqQuery, ReqHeaders, ResHeaders, LocalsObj, BaseRequest, BaseResponse, NextFunction> | ConstrainedForklaunchRouter<SV, RouterHandler>, ...middlewareOrMiddlewareWithTypedHandler: (MiddlewareOrMiddlewareWithTypedHandler<SV, 'middleware', Path, P, ResBodyMap, ReqBody, ReqQuery, ReqHeaders, ResHeaders, LocalsObj, BaseRequest, BaseResponse, NextFunction> | ConstrainedForklaunchRouter<SV, RouterHandler>)[]): this;
|
@@ -752,12 +775,13 @@ declare class ForklaunchExpressLikeRouter<SV extends AnySchemaValidator, BasePat
|
|
752
775
|
declare abstract class ForklaunchExpressLikeApplication<SV extends AnySchemaValidator, Server extends ExpressLikeRouter<RouterHandler, Server>, RouterHandler, BaseRequest, BaseResponse, NextFunction> extends ForklaunchExpressLikeRouter<SV, '/', RouterHandler, Server, BaseRequest, BaseResponse, NextFunction> {
|
753
776
|
readonly schemaValidator: SV;
|
754
777
|
readonly internal: Server;
|
778
|
+
readonly openTelemetryCollector: OpenTelemetryCollector<MetricsDefinition>;
|
755
779
|
/**
|
756
780
|
* Creates an instance of the Application class.
|
757
781
|
*
|
758
782
|
* @param {SV} schemaValidator - The schema validator.
|
759
783
|
*/
|
760
|
-
constructor(schemaValidator: SV, internal: Server);
|
784
|
+
constructor(schemaValidator: SV, internal: Server, openTelemetryCollector: OpenTelemetryCollector<MetricsDefinition>);
|
761
785
|
abstract listen(...args: unknown[]): void;
|
762
786
|
}
|
763
787
|
|
@@ -914,43 +938,20 @@ declare function generateSwaggerDocument<SV extends AnySchemaValidator>(schemaVa
|
|
914
938
|
declare const ATTR_API_NAME = "api.name";
|
915
939
|
declare const ATTR_CORRELATION_ID = "correlation.id";
|
916
940
|
|
917
|
-
type MetricType<T extends string> = T extends 'counter' ? Counter : T extends 'gauge' ? Gauge : T extends 'histogram' ? Histogram : T extends 'upDownCounter' ? UpDownCounter : T extends 'observableCounter' ? ObservableCounter : T extends 'observableGauge' ? ObservableGauge : T extends 'observableUpDownCounter' ? ObservableUpDownCounter : undefined;
|
918
|
-
type MetricsDefinition = Record<string, 'counter' | 'gauge' | 'histogram' | 'upDownCounter' | 'observableCounter' | 'observableGauge' | 'observableUpDownCounter'>;
|
919
|
-
|
920
941
|
declare function metricsDefinitions<T extends MetricsDefinition>(metrics: T): T;
|
921
942
|
|
922
|
-
declare
|
923
|
-
private readonly serviceName;
|
924
|
-
private readonly logger;
|
925
|
-
private readonly metrics;
|
926
|
-
constructor(serviceName: string, level?: LevelWithSilentOrString, metricDefinitions?: AppliedMetricsDefinition);
|
927
|
-
log(level: LevelWithSilent, msg: string, meta?: AnyValueMap): void;
|
928
|
-
info(msg: string, meta?: AnyValueMap): void;
|
929
|
-
error(msg: string, meta?: AnyValueMap): void;
|
930
|
-
warn(msg: string, meta?: AnyValueMap): void;
|
931
|
-
debug(msg: string, meta?: AnyValueMap): void;
|
932
|
-
trace(msg: string, meta?: AnyValueMap): void;
|
933
|
-
getMetric<T extends keyof AppliedMetricsDefinition>(metricId: T): MetricType<AppliedMetricsDefinition[T]>;
|
934
|
-
}
|
935
|
-
declare const httpRequestsTotalCounter: Counter<{
|
936
|
-
"service.name": string;
|
937
|
-
"api.name": string;
|
938
|
-
"correlation.id": string;
|
939
|
-
"http.request.method": string;
|
940
|
-
"http.route": string;
|
941
|
-
"http.response.status_code": number;
|
942
|
-
}>;
|
943
|
-
|
943
|
+
declare function meta(meta: Record<string, unknown>): LoggerMeta;
|
944
944
|
declare class PinoLogger {
|
945
945
|
private pinoLogger;
|
946
946
|
private meta;
|
947
|
+
private prettyPrinter;
|
947
948
|
constructor(level: LevelWithSilentOrString, meta?: AnyValueMap);
|
948
|
-
log(level: LevelWithSilent,
|
949
|
-
error
|
950
|
-
info
|
951
|
-
debug
|
952
|
-
warn
|
953
|
-
trace
|
949
|
+
log(level: LevelWithSilent, ...args: (string | unknown | LoggerMeta)[]): void;
|
950
|
+
error: LogFn;
|
951
|
+
info: LogFn;
|
952
|
+
debug: LogFn;
|
953
|
+
warn: LogFn;
|
954
|
+
trace: LogFn;
|
954
955
|
child(meta?: AnyValueMap): PinoLogger;
|
955
956
|
getBaseLogger(): Logger;
|
956
957
|
}
|
@@ -958,4 +959,4 @@ declare function logger(level: LevelWithSilentOrString, meta?: AnyValueMap): Pin
|
|
958
959
|
|
959
960
|
declare function recordMetric<SV extends AnySchemaValidator, P extends ParamsDictionary, ReqBody extends Record<string, unknown>, ReqQuery extends ParsedQs, ResBodyMap extends Record<string, unknown>, ReqHeaders extends Record<string, string>, ResHeaders extends Record<string, string>, LocalsObj extends Record<string, unknown>>(req: ForklaunchRequest<SV, P, ReqBody, ReqQuery, ReqHeaders>, res: ForklaunchResponse<ResBodyMap, ResHeaders, LocalsObj>): void;
|
960
961
|
|
961
|
-
export { ATTR_API_NAME, ATTR_CORRELATION_ID, type ApiClient, type AuthMethods, type AuthMethodsBase, type Body, type BodyObject, type ConstrainedForklaunchRouter, type ContractDetails, type ContractDetailsExpressLikeSchemaHandler, type ContractDetailsOrMiddlewareOrTypedHandler, type ErrorContainer, type ExpressLikeAuthMapper, type ExpressLikeHandler, type ExpressLikeRouter, type ExpressLikeSchemaAuthMapper, type ExpressLikeSchemaHandler, type ExpressLikeTypedHandler, type ExtractedParamsObject, type ForklaunchBaseRequest, ForklaunchExpressLikeApplication, ForklaunchExpressLikeRouter, type ForklaunchNextFunction, type ForklaunchRequest, type ForklaunchResErrors, type ForklaunchResHeaders, type ForklaunchResponse, type ForklaunchRoute, type ForklaunchRouter, type ForklaunchSendableData, type ForklaunchStatusResponse, HTTPStatuses, type HeadersObject, type HttpContractDetails, type HttpMethod, type LiveTypeFunction, type LiveTypeRouteDefinition, type MapParamsSchema, type MapReqBodySchema, type MapReqHeadersSchema, type MapReqQuerySchema, type MapResBodyMapSchema, type MapResHeadersSchema, type MapSchema, type Method,
|
962
|
+
export { ATTR_API_NAME, ATTR_CORRELATION_ID, type ApiClient, type AuthMethods, type AuthMethodsBase, type Body, type BodyObject, type ConstrainedForklaunchRouter, type ContractDetails, type ContractDetailsExpressLikeSchemaHandler, type ContractDetailsOrMiddlewareOrTypedHandler, type ErrorContainer, type ExpressLikeAuthMapper, type ExpressLikeHandler, type ExpressLikeRouter, type ExpressLikeSchemaAuthMapper, type ExpressLikeSchemaHandler, type ExpressLikeTypedHandler, type ExtractedParamsObject, type ForklaunchBaseRequest, ForklaunchExpressLikeApplication, ForklaunchExpressLikeRouter, type ForklaunchNextFunction, type ForklaunchRequest, type ForklaunchResErrors, type ForklaunchResHeaders, type ForklaunchResponse, type ForklaunchRoute, type ForklaunchRouter, type ForklaunchSendableData, type ForklaunchStatusResponse, HTTPStatuses, type HeadersObject, type HttpContractDetails, type HttpMethod, type LiveTypeFunction, type LiveTypeRouteDefinition, LogFn, LoggerMeta, type MapParamsSchema, type MapReqBodySchema, type MapReqHeadersSchema, type MapReqQuerySchema, type MapResBodyMapSchema, type MapResHeadersSchema, type MapSchema, type Method, MetricsDefinition, type MiddlewareContractDetails, type MiddlewareOrMiddlewareWithTypedHandler, type NestableRouterBasedHandler, type NumberOnlyObject, OpenTelemetryCollector, type ParamsDictionary, type ParamsObject, type PathBasedHandler, type PathMatch, type PathOrMiddlewareBasedHandler, type PathParamHttpContractDetails, type PathParamMethod, type QueryObject, type RequestContext, type ResolvedForklaunchRequest, type ResponseCompiledSchema, type ResponseShape, type ResponsesObject, type SchemaAuthMethods, type StatusCode, type StringOnlyObject, type TypedHandler, type TypedMiddlewareDefinition, type TypedNestableMiddlewareDefinition, delete_, enrichExpressLikeSend, generateSwaggerDocument, get, getCodeForStatus, head, isClientError, isForklaunchRequest, isForklaunchRouter, isInformational, isRedirection, isServerError, isSuccessful, isValidStatusCode, logger, meta, metricsDefinitions, middleware, options, patch, post, put, recordMetric, trace, typedHandler };
|
package/lib/http/index.d.ts
CHANGED
@@ -1,7 +1,10 @@
|
|
1
1
|
import { AnySchemaValidator, UnboxedObjectSchema, IdiomaticSchema, Schema } from '@forklaunch/validator';
|
2
2
|
import { Prettify, RemoveTrailingSlash, MakePropertyOptionalIfChildrenOptional } from '@forklaunch/common';
|
3
|
-
import { Span
|
3
|
+
import { Span } from '@opentelemetry/api';
|
4
4
|
import { ParsedQs } from 'qs';
|
5
|
+
import { Readable } from 'stream';
|
6
|
+
import { O as OpenTelemetryCollector, M as MetricsDefinition, L as LoggerMeta, a as LogFn } from '../openTelemetryCollector-CWrfzmmW.js';
|
7
|
+
export { c as MetricType, h as httpRequestsTotalCounter, b as httpServerDurationHistogram } from '../openTelemetryCollector-CWrfzmmW.js';
|
5
8
|
import { OpenAPIObject } from 'openapi3-ts/oas31';
|
6
9
|
import { AnyValueMap } from '@opentelemetry/api-logs';
|
7
10
|
import { LevelWithSilentOrString, LevelWithSilent, Logger } from 'pino';
|
@@ -292,6 +295,8 @@ interface ForklaunchRequest<SV extends AnySchemaValidator, P extends ParamsDicti
|
|
292
295
|
requestSchema: unknown;
|
293
296
|
/** Original path */
|
294
297
|
originalPath: string;
|
298
|
+
/** OpenTelemetry Collector */
|
299
|
+
openTelemetryCollector: OpenTelemetryCollector<MetricsDefinition>;
|
295
300
|
}
|
296
301
|
/**
|
297
302
|
* Represents the types of data that can be sent in a response.
|
@@ -355,6 +360,18 @@ interface ForklaunchResponse<ResBodyMap extends Record<number, unknown>, ResHead
|
|
355
360
|
* @param {string} value - The header value.
|
356
361
|
*/
|
357
362
|
setHeader: <K extends keyof (ResHeaders & ForklaunchResHeaders)>(key: K, value: K extends keyof ForklaunchResHeaders ? ForklaunchResHeaders[K] : ResHeaders[K]) => void;
|
363
|
+
/**
|
364
|
+
* Adds an event listener to the response.
|
365
|
+
* @param {string} event - The event to listen for.
|
366
|
+
* @param {Function} listener - The listener function.
|
367
|
+
*/
|
368
|
+
on(event: 'close', listener: () => void): this;
|
369
|
+
on(event: 'drain', listener: () => void): this;
|
370
|
+
on(event: 'error', listener: (err: Error) => void): this;
|
371
|
+
on(event: 'finish', listener: () => void): this;
|
372
|
+
on(event: 'pipe', listener: (src: Readable) => void): this;
|
373
|
+
on(event: 'unpipe', listener: (src: Readable) => void): this;
|
374
|
+
on(event: string | symbol, listener: (...args: unknown[]) => void): this;
|
358
375
|
/**
|
359
376
|
* Sets the status of the response.
|
360
377
|
* @param {U} code - The status code.
|
@@ -370,6 +387,11 @@ interface ForklaunchResponse<ResBodyMap extends Record<number, unknown>, ResHead
|
|
370
387
|
* @param {string} [data] - Optional data to send.
|
371
388
|
*/
|
372
389
|
end: (data?: string) => void;
|
390
|
+
/**
|
391
|
+
* Sets the content type of the response.
|
392
|
+
* @param {string} type - The content type.
|
393
|
+
*/
|
394
|
+
type: (type: string) => void;
|
373
395
|
/** Local variables */
|
374
396
|
locals: LocalsObj;
|
375
397
|
/** Cors */
|
@@ -618,11 +640,12 @@ declare class ForklaunchExpressLikeRouter<SV extends AnySchemaValidator, BasePat
|
|
618
640
|
#private;
|
619
641
|
readonly schemaValidator: SV;
|
620
642
|
readonly internal: Internal;
|
643
|
+
readonly openTelemetryCollector: OpenTelemetryCollector<MetricsDefinition>;
|
621
644
|
requestHandler: RouterHandler;
|
622
645
|
routers: ForklaunchRouter<SV>[];
|
623
646
|
readonly routes: ForklaunchRoute<SV>[];
|
624
647
|
readonly basePath: BasePath;
|
625
|
-
constructor(basePath: BasePath, schemaValidator: SV, internal: Internal);
|
648
|
+
constructor(basePath: BasePath, schemaValidator: SV, internal: Internal, openTelemetryCollector: OpenTelemetryCollector<MetricsDefinition>);
|
626
649
|
registerRoute<ContractMethod extends Method, Path extends `/${string}`, P extends ParamsObject<SV>, ResBodyMap extends ResponsesObject<SV>, ReqBody extends Body<SV>, ReqQuery extends QueryObject<SV>, ReqHeaders extends HeadersObject<SV>, ResHeaders extends HeadersObject<SV>, LocalsObj extends Record<string, unknown>>(method: ContractMethod, path: Path, registrationMethod: PathBasedHandler<RouterHandler>, contractDetailsOrMiddlewareOrTypedHandler: ContractDetailsOrMiddlewareOrTypedHandler<SV, ContractMethod, Path, P, ResBodyMap, ReqBody, ReqQuery, ReqHeaders, ResHeaders, LocalsObj, BaseRequest, BaseResponse, NextFunction>, ...middlewareOrMiddlewareAndTypedHandler: MiddlewareOrMiddlewareWithTypedHandler<SV, ContractMethod, Path, P, ResBodyMap, ReqBody, ReqQuery, ReqHeaders, ResHeaders, LocalsObj, BaseRequest, BaseResponse, NextFunction>[]): LiveTypeFunction<SV, `${BasePath}${Path}`, P, ResBodyMap, ReqBody, ReqQuery, ReqHeaders, ResHeaders>;
|
627
650
|
registerMiddlewareHandler<Path extends `/${string}`, P extends ParamsObject<SV>, ResBodyMap extends ResponsesObject<SV>, ReqBody extends Body<SV>, ReqQuery extends QueryObject<SV>, ReqHeaders extends HeadersObject<SV>, ResHeaders extends HeadersObject<SV>, LocalsObj extends Record<string, unknown>>(registrationMethod: PathOrMiddlewareBasedHandler<RouterHandler>, pathOrContractDetailsOrMiddlewareOrTypedHandler: Path | ContractDetailsOrMiddlewareOrTypedHandler<SV, 'middleware', Path, P, ResBodyMap, ReqBody, ReqQuery, ReqHeaders, ResHeaders, LocalsObj, BaseRequest, BaseResponse, NextFunction>, contractDetailsOrMiddlewareOrTypedHandler?: ContractDetailsOrMiddlewareOrTypedHandler<SV, 'middleware', Path, P, ResBodyMap, ReqBody, ReqQuery, ReqHeaders, ResHeaders, LocalsObj, BaseRequest, BaseResponse, NextFunction>, ...middlewareOrMiddlewareWithTypedHandler: MiddlewareOrMiddlewareWithTypedHandler<SV, 'middleware', Path, P, ResBodyMap, ReqBody, ReqQuery, ReqHeaders, ResHeaders, LocalsObj, BaseRequest, BaseResponse, NextFunction>[]): this;
|
628
651
|
registerNestableMiddlewareHandler<Path extends `/${string}`, P extends ParamsObject<SV>, ResBodyMap extends ResponsesObject<SV>, ReqBody extends Body<SV>, ReqQuery extends QueryObject<SV>, ReqHeaders extends HeadersObject<SV>, ResHeaders extends HeadersObject<SV>, LocalsObj extends Record<string, unknown>>(registrationMethod: NestableRouterBasedHandler<RouterHandler, Internal>, pathOrContractDetailsOrMiddlewareOrTypedHandler: Path | ContractDetailsOrMiddlewareOrTypedHandler<SV, 'middleware', Path, P, ResBodyMap, ReqBody, ReqQuery, ReqHeaders, ResHeaders, LocalsObj, BaseRequest, BaseResponse, NextFunction> | ConstrainedForklaunchRouter<SV, RouterHandler>, contractDetailsOrMiddlewareOrTypedHandler?: ContractDetailsOrMiddlewareOrTypedHandler<SV, 'middleware', Path, P, ResBodyMap, ReqBody, ReqQuery, ReqHeaders, ResHeaders, LocalsObj, BaseRequest, BaseResponse, NextFunction> | ConstrainedForklaunchRouter<SV, RouterHandler>, ...middlewareOrMiddlewareWithTypedHandler: (MiddlewareOrMiddlewareWithTypedHandler<SV, 'middleware', Path, P, ResBodyMap, ReqBody, ReqQuery, ReqHeaders, ResHeaders, LocalsObj, BaseRequest, BaseResponse, NextFunction> | ConstrainedForklaunchRouter<SV, RouterHandler>)[]): this;
|
@@ -752,12 +775,13 @@ declare class ForklaunchExpressLikeRouter<SV extends AnySchemaValidator, BasePat
|
|
752
775
|
declare abstract class ForklaunchExpressLikeApplication<SV extends AnySchemaValidator, Server extends ExpressLikeRouter<RouterHandler, Server>, RouterHandler, BaseRequest, BaseResponse, NextFunction> extends ForklaunchExpressLikeRouter<SV, '/', RouterHandler, Server, BaseRequest, BaseResponse, NextFunction> {
|
753
776
|
readonly schemaValidator: SV;
|
754
777
|
readonly internal: Server;
|
778
|
+
readonly openTelemetryCollector: OpenTelemetryCollector<MetricsDefinition>;
|
755
779
|
/**
|
756
780
|
* Creates an instance of the Application class.
|
757
781
|
*
|
758
782
|
* @param {SV} schemaValidator - The schema validator.
|
759
783
|
*/
|
760
|
-
constructor(schemaValidator: SV, internal: Server);
|
784
|
+
constructor(schemaValidator: SV, internal: Server, openTelemetryCollector: OpenTelemetryCollector<MetricsDefinition>);
|
761
785
|
abstract listen(...args: unknown[]): void;
|
762
786
|
}
|
763
787
|
|
@@ -914,43 +938,20 @@ declare function generateSwaggerDocument<SV extends AnySchemaValidator>(schemaVa
|
|
914
938
|
declare const ATTR_API_NAME = "api.name";
|
915
939
|
declare const ATTR_CORRELATION_ID = "correlation.id";
|
916
940
|
|
917
|
-
type MetricType<T extends string> = T extends 'counter' ? Counter : T extends 'gauge' ? Gauge : T extends 'histogram' ? Histogram : T extends 'upDownCounter' ? UpDownCounter : T extends 'observableCounter' ? ObservableCounter : T extends 'observableGauge' ? ObservableGauge : T extends 'observableUpDownCounter' ? ObservableUpDownCounter : undefined;
|
918
|
-
type MetricsDefinition = Record<string, 'counter' | 'gauge' | 'histogram' | 'upDownCounter' | 'observableCounter' | 'observableGauge' | 'observableUpDownCounter'>;
|
919
|
-
|
920
941
|
declare function metricsDefinitions<T extends MetricsDefinition>(metrics: T): T;
|
921
942
|
|
922
|
-
declare
|
923
|
-
private readonly serviceName;
|
924
|
-
private readonly logger;
|
925
|
-
private readonly metrics;
|
926
|
-
constructor(serviceName: string, level?: LevelWithSilentOrString, metricDefinitions?: AppliedMetricsDefinition);
|
927
|
-
log(level: LevelWithSilent, msg: string, meta?: AnyValueMap): void;
|
928
|
-
info(msg: string, meta?: AnyValueMap): void;
|
929
|
-
error(msg: string, meta?: AnyValueMap): void;
|
930
|
-
warn(msg: string, meta?: AnyValueMap): void;
|
931
|
-
debug(msg: string, meta?: AnyValueMap): void;
|
932
|
-
trace(msg: string, meta?: AnyValueMap): void;
|
933
|
-
getMetric<T extends keyof AppliedMetricsDefinition>(metricId: T): MetricType<AppliedMetricsDefinition[T]>;
|
934
|
-
}
|
935
|
-
declare const httpRequestsTotalCounter: Counter<{
|
936
|
-
"service.name": string;
|
937
|
-
"api.name": string;
|
938
|
-
"correlation.id": string;
|
939
|
-
"http.request.method": string;
|
940
|
-
"http.route": string;
|
941
|
-
"http.response.status_code": number;
|
942
|
-
}>;
|
943
|
-
|
943
|
+
declare function meta(meta: Record<string, unknown>): LoggerMeta;
|
944
944
|
declare class PinoLogger {
|
945
945
|
private pinoLogger;
|
946
946
|
private meta;
|
947
|
+
private prettyPrinter;
|
947
948
|
constructor(level: LevelWithSilentOrString, meta?: AnyValueMap);
|
948
|
-
log(level: LevelWithSilent,
|
949
|
-
error
|
950
|
-
info
|
951
|
-
debug
|
952
|
-
warn
|
953
|
-
trace
|
949
|
+
log(level: LevelWithSilent, ...args: (string | unknown | LoggerMeta)[]): void;
|
950
|
+
error: LogFn;
|
951
|
+
info: LogFn;
|
952
|
+
debug: LogFn;
|
953
|
+
warn: LogFn;
|
954
|
+
trace: LogFn;
|
954
955
|
child(meta?: AnyValueMap): PinoLogger;
|
955
956
|
getBaseLogger(): Logger;
|
956
957
|
}
|
@@ -958,4 +959,4 @@ declare function logger(level: LevelWithSilentOrString, meta?: AnyValueMap): Pin
|
|
958
959
|
|
959
960
|
declare function recordMetric<SV extends AnySchemaValidator, P extends ParamsDictionary, ReqBody extends Record<string, unknown>, ReqQuery extends ParsedQs, ResBodyMap extends Record<string, unknown>, ReqHeaders extends Record<string, string>, ResHeaders extends Record<string, string>, LocalsObj extends Record<string, unknown>>(req: ForklaunchRequest<SV, P, ReqBody, ReqQuery, ReqHeaders>, res: ForklaunchResponse<ResBodyMap, ResHeaders, LocalsObj>): void;
|
960
961
|
|
961
|
-
export { ATTR_API_NAME, ATTR_CORRELATION_ID, type ApiClient, type AuthMethods, type AuthMethodsBase, type Body, type BodyObject, type ConstrainedForklaunchRouter, type ContractDetails, type ContractDetailsExpressLikeSchemaHandler, type ContractDetailsOrMiddlewareOrTypedHandler, type ErrorContainer, type ExpressLikeAuthMapper, type ExpressLikeHandler, type ExpressLikeRouter, type ExpressLikeSchemaAuthMapper, type ExpressLikeSchemaHandler, type ExpressLikeTypedHandler, type ExtractedParamsObject, type ForklaunchBaseRequest, ForklaunchExpressLikeApplication, ForklaunchExpressLikeRouter, type ForklaunchNextFunction, type ForklaunchRequest, type ForklaunchResErrors, type ForklaunchResHeaders, type ForklaunchResponse, type ForklaunchRoute, type ForklaunchRouter, type ForklaunchSendableData, type ForklaunchStatusResponse, HTTPStatuses, type HeadersObject, type HttpContractDetails, type HttpMethod, type LiveTypeFunction, type LiveTypeRouteDefinition, type MapParamsSchema, type MapReqBodySchema, type MapReqHeadersSchema, type MapReqQuerySchema, type MapResBodyMapSchema, type MapResHeadersSchema, type MapSchema, type Method,
|
962
|
+
export { ATTR_API_NAME, ATTR_CORRELATION_ID, type ApiClient, type AuthMethods, type AuthMethodsBase, type Body, type BodyObject, type ConstrainedForklaunchRouter, type ContractDetails, type ContractDetailsExpressLikeSchemaHandler, type ContractDetailsOrMiddlewareOrTypedHandler, type ErrorContainer, type ExpressLikeAuthMapper, type ExpressLikeHandler, type ExpressLikeRouter, type ExpressLikeSchemaAuthMapper, type ExpressLikeSchemaHandler, type ExpressLikeTypedHandler, type ExtractedParamsObject, type ForklaunchBaseRequest, ForklaunchExpressLikeApplication, ForklaunchExpressLikeRouter, type ForklaunchNextFunction, type ForklaunchRequest, type ForklaunchResErrors, type ForklaunchResHeaders, type ForklaunchResponse, type ForklaunchRoute, type ForklaunchRouter, type ForklaunchSendableData, type ForklaunchStatusResponse, HTTPStatuses, type HeadersObject, type HttpContractDetails, type HttpMethod, type LiveTypeFunction, type LiveTypeRouteDefinition, LogFn, LoggerMeta, type MapParamsSchema, type MapReqBodySchema, type MapReqHeadersSchema, type MapReqQuerySchema, type MapResBodyMapSchema, type MapResHeadersSchema, type MapSchema, type Method, MetricsDefinition, type MiddlewareContractDetails, type MiddlewareOrMiddlewareWithTypedHandler, type NestableRouterBasedHandler, type NumberOnlyObject, OpenTelemetryCollector, type ParamsDictionary, type ParamsObject, type PathBasedHandler, type PathMatch, type PathOrMiddlewareBasedHandler, type PathParamHttpContractDetails, type PathParamMethod, type QueryObject, type RequestContext, type ResolvedForklaunchRequest, type ResponseCompiledSchema, type ResponseShape, type ResponsesObject, type SchemaAuthMethods, type StatusCode, type StringOnlyObject, type TypedHandler, type TypedMiddlewareDefinition, type TypedNestableMiddlewareDefinition, delete_, enrichExpressLikeSend, generateSwaggerDocument, get, getCodeForStatus, head, isClientError, isForklaunchRequest, isForklaunchRouter, isInformational, isRedirection, isServerError, isSuccessful, isValidStatusCode, logger, meta, metricsDefinitions, middleware, options, patch, post, put, recordMetric, trace, typedHandler };
|