@faapi/faapi 6.9.1 → 6.10.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.
- package/dist/cli/index.js +45 -35
- package/dist/cli/index.js.map +1 -1
- package/dist/index.d.ts +47 -21
- package/dist/index.js +45 -35
- package/dist/index.js.map +1 -1
- package/dist/{routeTypes-CuGMDCGB.d.ts → routeTypes-m9wZHWyo.d.ts} +9 -34
- package/dist/testing.d.ts +2 -4
- package/dist/testing.js +35 -33
- package/dist/testing.js.map +1 -1
- package/package.json +1 -1
package/dist/cli/index.js
CHANGED
|
@@ -6507,9 +6507,17 @@ function configureLogging(config) {
|
|
|
6507
6507
|
void globalState.fileSink?.close();
|
|
6508
6508
|
globalState.disabled = config === false;
|
|
6509
6509
|
globalState.sink = objectConfig.sink ?? null;
|
|
6510
|
-
globalState.accessLog = objectConfig.accessLog ??
|
|
6510
|
+
globalState.accessLog = objectConfig.accessLog ?? true;
|
|
6511
6511
|
globalState.stdout = objectConfig.stdout ?? true;
|
|
6512
6512
|
globalState.fileSink = objectConfig.dir ? createFileLogSink({ dir: objectConfig.dir, splitByLevel: objectConfig.splitByLevel }) : null;
|
|
6513
|
+
if (objectConfig.consoleLevel !== void 0) {
|
|
6514
|
+
if (objectConfig.consoleLevel !== false) {
|
|
6515
|
+
assertLogLevel(objectConfig.consoleLevel, "config.log.consoleLevel");
|
|
6516
|
+
}
|
|
6517
|
+
globalState.consoleLevel = objectConfig.consoleLevel;
|
|
6518
|
+
} else {
|
|
6519
|
+
globalState.consoleLevel = null;
|
|
6520
|
+
}
|
|
6513
6521
|
if (objectConfig.level !== void 0) {
|
|
6514
6522
|
assertLogLevel(objectConfig.level, "config.log.level");
|
|
6515
6523
|
globalState.level = objectConfig.level;
|
|
@@ -6520,43 +6528,48 @@ function configureLogging(config) {
|
|
|
6520
6528
|
globalState.level = null;
|
|
6521
6529
|
}
|
|
6522
6530
|
}
|
|
6523
|
-
function
|
|
6524
|
-
|
|
6525
|
-
|
|
6526
|
-
|
|
6531
|
+
function pipelineThreshold() {
|
|
6532
|
+
return globalState.level ?? void 0;
|
|
6533
|
+
}
|
|
6534
|
+
function consoleThreshold() {
|
|
6535
|
+
return globalState.consoleLevel ?? "info";
|
|
6527
6536
|
}
|
|
6528
6537
|
function belowThreshold(level, threshold) {
|
|
6529
6538
|
return threshold !== void 0 && LEVEL_RANK[level] < LEVEL_RANK[threshold];
|
|
6530
6539
|
}
|
|
6531
6540
|
function getEffectiveLogLevel() {
|
|
6532
|
-
return
|
|
6541
|
+
return pipelineThreshold();
|
|
6542
|
+
}
|
|
6543
|
+
function consoleDispatch(entry) {
|
|
6544
|
+
const threshold = consoleThreshold();
|
|
6545
|
+
if (threshold === false || belowThreshold(entry.level, threshold)) return;
|
|
6546
|
+
console[CONSOLE_METHOD[entry.level]](formatEntry(entry));
|
|
6533
6547
|
}
|
|
6534
6548
|
function globalDispatch(entry) {
|
|
6535
6549
|
if (globalState.disabled) return;
|
|
6550
|
+
const pipeThreshold = pipelineThreshold();
|
|
6536
6551
|
if (globalState.sink) {
|
|
6537
|
-
globalState.sink(entry);
|
|
6552
|
+
if (!belowThreshold(entry.level, pipeThreshold)) globalState.sink(entry);
|
|
6538
6553
|
return;
|
|
6539
6554
|
}
|
|
6540
6555
|
if (globalState.fileSink) {
|
|
6541
|
-
globalState.fileSink.write(entry);
|
|
6542
|
-
if (globalState.stdout)
|
|
6556
|
+
if (!belowThreshold(entry.level, pipeThreshold)) globalState.fileSink.write(entry);
|
|
6557
|
+
if (globalState.stdout) consoleDispatch(entry);
|
|
6543
6558
|
return;
|
|
6544
6559
|
}
|
|
6545
|
-
|
|
6560
|
+
consoleDispatch(entry);
|
|
6546
6561
|
}
|
|
6547
6562
|
function writeLogEntry(entry) {
|
|
6548
|
-
if (belowThreshold(entry.level, globalThreshold())) return;
|
|
6549
6563
|
globalDispatch(entry);
|
|
6550
6564
|
}
|
|
6551
|
-
function
|
|
6565
|
+
function isAccessLogEnabled() {
|
|
6552
6566
|
return !globalState.disabled && globalState.accessLog;
|
|
6553
6567
|
}
|
|
6554
6568
|
function createLogger(scope, options) {
|
|
6555
6569
|
const baseScope = scope;
|
|
6556
6570
|
const baseFields = options?.fields;
|
|
6557
6571
|
const write = (level, message, callFields, scopeSuffix) => {
|
|
6558
|
-
|
|
6559
|
-
if (belowThreshold(level, threshold)) return;
|
|
6572
|
+
if (belowThreshold(level, options?.level)) return;
|
|
6560
6573
|
const entry = {
|
|
6561
6574
|
level,
|
|
6562
6575
|
message,
|
|
@@ -6582,7 +6595,7 @@ function createLogger(scope, options) {
|
|
|
6582
6595
|
});
|
|
6583
6596
|
return makeLogger(void 0);
|
|
6584
6597
|
}
|
|
6585
|
-
var LEVEL_RANK, VALID_LEVELS, globalState,
|
|
6598
|
+
var LEVEL_RANK, VALID_LEVELS, globalState, CONSOLE_METHOD;
|
|
6586
6599
|
var init_logger = __esm({
|
|
6587
6600
|
"src/logger/logger.ts"() {
|
|
6588
6601
|
"use strict";
|
|
@@ -6590,9 +6603,14 @@ var init_logger = __esm({
|
|
|
6590
6603
|
init_fileSink();
|
|
6591
6604
|
LEVEL_RANK = { debug: 0, info: 1, warn: 2, error: 3 };
|
|
6592
6605
|
VALID_LEVELS = ["debug", "info", "warn", "error"];
|
|
6593
|
-
globalState = {
|
|
6594
|
-
|
|
6595
|
-
|
|
6606
|
+
globalState = {
|
|
6607
|
+
level: null,
|
|
6608
|
+
consoleLevel: null,
|
|
6609
|
+
sink: null,
|
|
6610
|
+
fileSink: null,
|
|
6611
|
+
stdout: true,
|
|
6612
|
+
accessLog: true,
|
|
6613
|
+
disabled: false
|
|
6596
6614
|
};
|
|
6597
6615
|
CONSOLE_METHOD = {
|
|
6598
6616
|
debug: "debug",
|
|
@@ -7947,18 +7965,14 @@ function levelForStatus(status) {
|
|
|
7947
7965
|
return "info";
|
|
7948
7966
|
}
|
|
7949
7967
|
function defaultLog(entry, text) {
|
|
7950
|
-
if (
|
|
7951
|
-
|
|
7952
|
-
|
|
7953
|
-
|
|
7954
|
-
|
|
7955
|
-
|
|
7956
|
-
|
|
7957
|
-
|
|
7958
|
-
writeLogEntry(logEntry);
|
|
7959
|
-
return;
|
|
7960
|
-
}
|
|
7961
|
-
console.log(entry);
|
|
7968
|
+
if (!isAccessLogEnabled()) return;
|
|
7969
|
+
writeLogEntry({
|
|
7970
|
+
level: levelForStatus(entry.status),
|
|
7971
|
+
message: text,
|
|
7972
|
+
time: (/* @__PURE__ */ new Date()).toISOString(),
|
|
7973
|
+
scope: "access",
|
|
7974
|
+
fields: entry
|
|
7975
|
+
});
|
|
7962
7976
|
}
|
|
7963
7977
|
function logger(options = {}) {
|
|
7964
7978
|
return async (ctx, next) => {
|
|
@@ -8365,7 +8379,6 @@ function createServer(options) {
|
|
|
8365
8379
|
compression: compressionOption,
|
|
8366
8380
|
etag: etagOption,
|
|
8367
8381
|
registries,
|
|
8368
|
-
logger: loggerOption,
|
|
8369
8382
|
bodyLimit = DEFAULT_BODY_LIMIT,
|
|
8370
8383
|
http2: http2Option,
|
|
8371
8384
|
trustedProxy = false
|
|
@@ -8382,8 +8395,7 @@ function createServer(options) {
|
|
|
8382
8395
|
const helmOpts = typeof helmetOption === "object" ? helmetOption : {};
|
|
8383
8396
|
configMiddlewares.push(helmet(helmOpts));
|
|
8384
8397
|
}
|
|
8385
|
-
|
|
8386
|
-
if (loggerMiddlewareInst) configMiddlewares.push(loggerMiddlewareInst);
|
|
8398
|
+
configMiddlewares.push(logger());
|
|
8387
8399
|
if (etagOption) {
|
|
8388
8400
|
const etagOpts = typeof etagOption === "object" ? etagOption : {};
|
|
8389
8401
|
configMiddlewares.push(etag(etagOpts));
|
|
@@ -9611,7 +9623,6 @@ async function createAppBase(options) {
|
|
|
9611
9623
|
helmet: config?.helmet,
|
|
9612
9624
|
compression: config?.compression,
|
|
9613
9625
|
etag: config?.etag,
|
|
9614
|
-
logger: config?.logger,
|
|
9615
9626
|
bodyLimit: config?.bodyLimit,
|
|
9616
9627
|
http2: config?.http2,
|
|
9617
9628
|
trustedProxy: config?.trustedProxy,
|
|
@@ -9916,7 +9927,6 @@ var init_createAppCore = __esm({
|
|
|
9916
9927
|
"compression",
|
|
9917
9928
|
"etag",
|
|
9918
9929
|
"bodyLimit",
|
|
9919
|
-
"logger",
|
|
9920
9930
|
"log",
|
|
9921
9931
|
"http2",
|
|
9922
9932
|
"trustedProxy",
|